Thursday, July 29, 2010

Logging off using the terminal

Open a terminal and type:
gnome-session-save --kill

if you dont want the log off window add --silent

Tuesday, July 27, 2010

How to install compiz

Compiz is a very great desktop effect application that runs on Linux environment, here how to install it

type in the terminal:
sudo apt-get install compiz compizconfig-settings-manager compiz-fusion-plugins-main compiz-fusion-plugins-extra emerald librsvg2-common

and

sudo apt-get install fusion-icon

Friday, July 23, 2010

How to create a custom symlink

If you compile some custom program and you need to run it without adding path
you can create a symlink(symbolic link) so that it will directed to the specified link

open terminal
type:
sudo ln -s /home/darshana/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns

Here I explained to add the symbolic link for ns (network simulator)

How to view CPU and RAM information from terminal

In some cases you are unable to use system monitor or any other tool to check what is your processor type, how much memory in the RAM. You can use /proc to view the information

To view cpu info
open a terminal
type:
less /proc/cpuinfo

To view ram information
open a terminal
type:
less /proc/meminfo

Sunday, July 18, 2010

How to convert a String to date object in Java

I am going to illustrate using an example

import java.util.Date;
import java.text.SimpleDateFormat;
public class test{
public static void main(String args[]){
String dateStr = "26/08/2010";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");

try{
Date date = formatter.parse(dateStr);
System.out.println("Date is : " + formatter.format(date));
}
catch (java.text.ParseException e){
e.printStackTrace();
}

}
}

Tuesday, July 13, 2010

How to use wget to download a file

As i know you cannot download wget to download files from the web sites which needs authentication or human verification.

but most of the times you can directly get the URL of the file,
open a terminal and type (without [])

wget -drc [URL]



if you need to pass from a proxy if you did not set the proxy address yet

 
export http_proxy="[url]:[port]"



example


export http_proxy="http://cache.pdn.ac.lk:3128"

Sunday, July 11, 2010

How to clear the page cache memory from terminal

When your page cache memory is full your computer will be really really slow and
you may be unable to run even a single program.

So open a terminal and type as a root user

sync; echo 3 > /proc/sys/vm/drop_caches



This will clear your cache memory and enables you to work faster than previously.

How to add a 'nop' using C

When you write a C code sometimes
you will need to add an assemble nop(No OPeration)
this is how it goes..


__asm__("nop");


for multiple nops add ';'

__asm__("nop;nop;nop");

Saturday, July 10, 2010

How to change Grub in ubuntu

Unlike other grub versions, Grub 2 can be edited from the GUI and it is very easy
here is the steps for Ubuntu 10.04,

open a terminal and run

sudo grub update
when the Grub update finished, run
sudo apt-get install 

for this you will need an Internet connection, if not download it from here
now open System->Administration->Startup-Manager