1) ifconfig = allows the operating system to setup network interfaces and allow the user to view information about the configured network interfaces



View the network settings on the Ethernet adapter currently used.

ifconfig eth0

View the network settings on the first Ethernet adapter installed in the computer.

ifconfig -a

Display into on all network interfaces on server, active or inactive.

ifconfig eth0 down

If eth0 exists would take it down causing it cannot send or receive any information.

ifconfig eth0 up

If eth0 exists and in the down state would return it back to the up state allowing to to send and receive information.

ifconfig eth0 netmask broadcast

Assign eth0 with the above values for IP, netmask and broadcast address.


2) ifup = bring a network interface up

ifup eth0 – bring up interface eth0


3) ifdown = bring a network interfacedown

ifdown eth2 – bring down interface eth2


4) ping = ping allows a user to ping another network IP address. This can help determine if the network is able to communicate with the network.


ping gmail.com – Would ping the gmailhost .com to see if it is alive.

ping gmail.com -c 1 – Would ping the hgmailost .com once and return to the command line


5) traceroute = print the route packets take to network host


$ traceroute google.co.in — Trace the route for Google Server.

$ traceroute -v — Show more details.

$ traceroute -n server — Print the HOP Address in numeric form.

$ traceroute -I server
— Use ICMP ECHO instead of UDP datagrams.

$ tracerout
e -i eth1 server — Use eth1 for send the probe packets.

$ traceroute server 100
— Sent 100 Bytes packet instead of default 40 Bytes packet.

6) host = simple utility for performing DNS (Domain Name Service) lookups.  It is normally used to convert names to IP addresses and vice versa


$ host google.com — Show the IP Address of Google.com.

$ host -v google.com — Show detailed output.

$ host -a google.com — Show more details.

$ host — Do reverse lookup and Show the host name.

$ host -l mydomain.com — List all hosts available in MyDomain.


7) dig = DNS lookup utility


dig yahoo.com


dig -x 192.168.52.

dig -t ANY yahoo.com


1) jobs = lists the jobs that you are running in the background and in the foreground


jobs [-p | -l] [-n] [-p] [-x] [job id]

If the prompt is returned with no information no jobs are present

jobs -p : list only the PID of process group leader

jobs -l : list only jobs that have change status since last notified by their status

jobs -r : resrict output to running jobs

jobs – s : restrict output to stopped jobs


2) bg = place a job in background

Normally user can run a job in background, by adding & at end of the
command (ex: sleep 10 &).

bg is a shell command. It is used to move a job from foreground to the
background, as if it had been started with `&’. If JOB is not present,
the shell’s notion of the current job is used.

Examples (follow all the steps below)

a) $ sleep 100 — Start a dummy job in foreground.   (sleep = waits a x amount of second)
Press Ctrl+z to stop the current job.

b) $ bg — Move the last stopped job to background.

c) $ sleep 150 — Dummy job 1
Press Ctrl+z to stop the current job.

d) $ sleep 140 — Dummy job 2
Press Ctrl+z to stop the current job.

e) $ sleep 130 — Dummy job 3
Press Ctrl+z to stop the current job.

f) $ jobs — List all active jobs.

g) $ bg 2 — Move the 2nd active job to background.


.3) fg = continues a stopped job by running it in the foreground


fg – Typing fg alone will resume the first job were it was left off.

fg 1 – specifying the job (in this case 1) will resume that particular job. The job id can be determined by running bg


4) nice = run a command with modified priority

nice command is used to run the given command with its scheduling
priority adjusted. Priority range goes from -20 (highest priority)
to 19 (lowest priority).


$ nice — Prints the current priority value.

$ nice ls — Increment the priority value of the ls command
by 10 (Default value) and run.

$ nice -n 5 ls — Increment the priority value of the ls command
by 5 and run.

# nice -n -2 ls — Decrement the priority value of the ls command by
-2 and run.

NOTE: Incrementing the priority value will reduce the priority level
and vice versa. Priority range is -20 (high) to 19 (low).


5) renice = renice is used to alters the scheduling priority of one or more
running processes, priority range goes from -20 (highest priority)
to 19 (lowest priority).


$ renice +1 123 — Increment the priority value of a process, which
process ID is 123.

# renice +1 123 — Decrement the priority value of a process, which
process ID is 123. (Root only can decrement ).

$ renice +1 -p 123 -p 200 — Same as above. Here no. of process is 2.

$ renice +1 -u sbharathi — Increment the priority value of all
processes, which is owned by a user (sbharathi).

$ renice +1 -g backup — Increment the priority value of all
processes, which is owned by a group (backup).

NOTE: Incrementing the priority value will reduce the priority level
and vice versa. Priority range is -20 (high) to 19 (low).


6) at = schedules a command to be ran at a particular time, such as a print job late at night

at –  executes commands at a specified time.
atq – lists the user’s pending jobs, unless the user is the superuser; in that case, everybody’s jobs are listed. The format of the output lines (one for each job) is: Job number, date, hour, job class.
atrm –  deletes jobs, identified by their job number.
batch – executes commands when system load levels permit; in other words, when the load average drops below 1.5, or the value specified in the invocation of atrun.


at -m 01:35 < atjob = Run the commands listed in the ‘atjob’ file at 1:35AM, in addition all output that is generated from job mail to the user running the task. When this command has been successfully enter you should receive a prompt similar to the below example.

commands will be executed using /bin/csh
job 1072250520.a at Wed Dec 24 00:22:00 2003

at -l = This command will list each of the scheduled jobs as seen below.

1072250520.a Wed Dec 24 00:22:00 2003

at -r 1072250520.a = Deletes the job just created.


atrm 23 = Deletes job 23.

If you wish to create a job that is repeated you could modify the file that executes the commands with another command that recreates the job or better yet use the crontab command.

Note: Performing just the at command at the prompt will give you an error “Garbled Time”, this is a standard error message if no switch or time setting is given.


7) top = provide information (frequently refreshed) about the most CPU-intensive processes currently running

Description of the fields

a: PID — Process Id
The task’s unique process ID, which periodically wraps, though never restarting at zero.
b: PPID — Parent Process Pid
The process ID of a task’s parent.
c: RUSER — Real User Name
The real user name of the task’s owner.
d: UID — User Id
The effective user ID of the task’s owner.
e: USER — User Name
The effective user name of the task’s owner.
f: GROUP — Group Name
The effective group name of the task’s owner.
g: TTY — Controlling Tty
The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input or output. However, a task need not be associated with a terminal, in which case you’ll see ‘?’ displayed.
h: PR — Priority
The priority of the task.
i: NI — Nice value
The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task’s dispatchability./dd>
j: P — Last used CPU (SMP)
A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. Also, the very act of running top may break this weak affinity and cause more processes to change CPUs more often (because of the extra demand for cpu time).
k: %CPU — CPU usage
The task’s share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if ‘Irix mode’ is Off, top will operate in ‘Solaris mode’ where a task’s cpu usage will be divided by the total number of CPUs. You toggle ‘Irix/Solaris’ modes with the ‘I’ interactive command.
l: TIME — CPU Time
Total CPU time the task has used since it started. When ‘Cumulative mode’ is On, each process is listed with the cpu time that it and its dead children has used. You toggle ‘Cumulative mode’ with ‘S’, which is a command-line option and an interactive command. See the ‘S’ interactive command for additional information regarding this mode.
m: TIME+ — CPU Time, hundredths
The same as ‘TIME’, but reflecting more granularity through hundredths of a second.
n: %MEM — Memory usage (RES)
A task’s currently used share of available physical memory.
o: VIRT — Virtual Image (kb)
The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out.


p: SWAP — Swapped size (kb)
The swapped out portion of a task’s total virtual memory image.
q: RES — Resident size (kb)
The non-swapped physical memory a task has used.


r: CODE — Code size (kb)
The amount of physical memory devoted to executable code, also known as the ‘text resident set’ size or TRS.
s: DATA — Data+Stack size (kb)
The amount of physical memory devoted to other than executable code, also known as the ‘data resident set’ size or DRS.
t: SHR — Shared Mem size (kb)
The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.
u: nFLT — Page Fault count
The number of major page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. A major page fault is when disk access is involved in making that page available.
v: nDRT — Dirty Pages count
The number of pages that have been modified since they were last written to disk. Dirty pages must be written to disk before the corresponding physical memory location can be used for some other virtual page.
w: S — Process Status
The status of the task which can be one of:
‘D’ = uninterruptible sleep
‘R’ = running
‘S’ = sleeping
‘T’ = traced or stopped
‘Z’ = zombieTasks shown as running should be more properly thought of as ‘ready to run’ — their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top’s delay interval and nice value.
x: Command — Command line or Program name
Display the command line used to start a task or the name of the associated program. You toggle between command line and name with ‘c’, which is both a command-line option and an interactive command.When you’ve chosen to display command lines, processes without a command line (like kernel threads) will be shown with only the program name in parentheses, as in this example:( mdrecoveryd )

Either form of display is subject to potential truncation if it’s too long to fit in this field’s current width. That width depends upon other fields selected, their order and the current screen width.

Note: The ‘Command’ field/column is unique, in that it is not fixed-width. When displayed, this column will be allocated all remaining screen width (up to the maximum 512 characters) to provide for the potential growth of program names into command lines.

y: WCHAN — Sleeping in Function
Depending on the availability of the kernel link map (‘System.map’), this field will show the name or the address of the kernel function in which the task is currently sleeping. Running tasks will display a dash (‘-‘) in this column.Note: By displaying this field, top’s own working set will be
increased by over 700Kb. Your only means of reducing that overhead
will be to stop and restart top.
z: Flags — Task Flags
This column represents the task’s current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in . Less formal documentation can also be found on the ‘Fields select’ and ‘Order fields’ screens.


Interactive commands

While top is running you may issue some options that will interact immediately with top these options are:

Help, displays a summary of command that will modify the behavior of top
Kills a process, you will be able to kill only your own processes, unless you are running top as root
Once this command is entered top will ask you how many lines you want on your screen, if you enter 0 top will display as much as it can
Exits top
Change the priority of a process, as well as with k you will only be able to act on your own processes unless you are root
Writes the current configuration to your personal configuration file, which is $HOME/.toprc

1) ps = report process status

ps : typing ps alone would list the current running processes

ps -u username : to search processes run by a certain user

ps ag : to get information about all running process

ps aux : to display the owner of the processes along with the processes

ps ax | grep  processname : to see if a particular process is running or not


2) ptree : to display a tree of processeses

pstree -p | less : also display the pid of the process


3) pgrep : look up or signal processes based on name and other attributes

pgrep sshd : to list the processes called sshd

pgrep -u root sshd : will only list the processes called sshd AND owned by root

pgrep -u root,daemon : will list the processes owned by root OR daemon


4) pidof — find the process ID of a running program

pidof emacs – list the process id for emacs

pgrep and pidof is much the same except that grep is more powerful it has more options (check man pages for both)


5) pkill = kill all processes matching the search text

pkill sshd : kill all sshd processes

pkill -9 –u userlogin : kill a process owned by a particular user


6) kill = Send a signal to terminate one or more process IDs

kill 2345 : terminate process 2345 (to list process id use ps)

kill -9 2345 : if kill 2345 doesnt work, use kill -9 2345 to force it


7) killall = kill all processes by name

killall nautilus

Unlike the kill command, it is not necessary to first try to find the PID(s) for nautilus. And if there are multiple instances of nautilus running, all will be terminated immediately.

killall is similar to pkill

1) su = become super user or another user


I already login as a normal user. To switch to root I can type

su <enter> : it will ask for root password then will log in to root account but maintaining the user environment

su root <enter> : same as above

su – <enter> : after entering the root password it will log in to root account with root environment (processing all login scripts)

su – david <enter> : login to david’s account with david’s environment

The difference between su and su – is one will maintain the user environment while the other will use the new user environment


2) sudo = execute a command as another user, as specified in the sudoers file.

a) by default, sudo requires that users authenticate themselves with a password (not root password)

b) sudo determines who is an authorized user by consulting the file /etc/sudoers. the login access have to be created by root user in this file

c) basically sudo is used to give access to superusers to do administrative job without them login using root account, so monitoring of each task done by many administrators can be recorded properly


sudo more /etc/sudoers : in order to view a content where the user has no access, he can use sudo

sudo shutdown -h now : to shutdown a machine

using sudo is by just adding the word sudo in front of any command that requires root/superuser privileges


3) wc = wc displays a count of lines, words, and characters in a file


wc resignationletter.txt

output is : 10   52   121  resignationletter.txt

10 = lines,  52 = words, 121 = characters

wc -w resignationletter.txt

the command above is to get only the word count

wc -c filename : to get the character count

wc -l filename : to get the number of lines in the document


4) cut = takes a vertical slice of a file, printing only the specified columns or fields

Eg 1 : For Findind List of users available on your linux machine
( see the previous post)

cut -d : -f 1 /etc/passwd

/etc/passwd is the file about user information , the general format of this file is


x means password is in /etc/shadow field

now i want ot retrieve the all username and their userid from that file
the command is

cut -d : -f 1 3 /etc/passwd

cut – command name
-d – delimiter (:)
-f – field numbers seperated by space (1 -username , 3 – userid)

Eg 2: the same like we can retrieve the groups details from /etc/groups

cut -d : -f 1 /etc/groups

taken from http://linuxforadmin.blogspot.com/2007/08/cut-command.html


5) diff = displays two files and prints the lines that are different


diff filenew.txt fileold.txt : use to compare the different between the two files.

more examples at http://lowfatlinux.com/linux-compare-files-diff.html

1) chown :  change file owner and group

To check the ownership of a file or directory use ls -l

Usage: chown [-Rcfv] newowner filenames/directory. Take note only root can change the ownership.


chown linda file.txt

This will cause file.txt to now be owned by linda.

chown -R abu:sales /home/account/

This is going to make all files inside /home/account/ and its subdirectories to belong to abu and to be associated with the group sales. -R means include all subdirectories


2) chgrp : change group ownership

Usage : chgrp [-Rcfv] groupname foo.txt


chgrp marketing file.txt – to change the group specified to a certain document

chgrp oracle /usr/database – to change the group specified to a certain directory

chgrp -R marketing /sales/2008 – to change the group specified to a certain directory recursively


3) chmod : to change the permissions of a file or directory. Use ls -l to see the permission settings.

Below is how the permission is assigned.

rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000

and so on...

rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-x = 101 in binary = 5
r-- = 100 in binary = 4

For example, if we wanted to set some_file to have read and write permission for the owner, but wanted to keep the file private from others, we would:

chmod 600 some_file

Here is a table of numbers that covers all the common settings. The ones beginning with “7” are used with programs (since they enable execution) and the rest are for other kinds of files.

Value Meaning
777 (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
755 (rwxr-xr-x) The file’s owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
700 (rwx——) The file’s owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
666 (rw-rw-rw-) All users may read and write the file.
644 (rw-r–r–) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
600 (rw——-) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.

Here are some useful settings for directories:

Value Meaning
777 (rwxrwxrwx) No restrictions on permissions. Anybody may list files, create new files in the directory and delete files in the directory. Generally not a good setting.
755 (rwxr-xr-x) The directory owner has full access. All others may list the directory, but cannot create files nor delete them. This setting is common for directories that you wish to share with other users.
700 (rwx——) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.

taken from http://www.linuxcommand.org/lts0070.php

chmod Shortcuts


The “who” is a list of letters that specifies whom you’re going to be giving permissions to. These may be specified in any order.

u The user who owns the file (this means “you.”)
g The group the file belongs to.
o The other users
a all of the above (an abbreviation for ugo)



Of course, the permissions are the same letters that you see in the directory listing:

r Permission to read the file.
w Permission to write (or delete) the file.
x Permission to execute the file, or, in the case of a directory, search it.

Let’s say we have these files:

-rwxrwxrwx  joe  acctg  wordmatic
-r--r--r--  joe  acctg  calcmatic

We’d like to remove write permission for the group and others on wordmatic, and add write and execute permission for all users on calcmatic.

Rather than try to figure out what the new permissions are and do these commands:

   chmod go=rx wordmatic
   chmod a=rwx calcmatic

The chmod command literally lets us add and subtract permissions from an existing set by using + or - instead of =.

Thus, we can take away the first file’s write permission for the group and others with this command:

   chmod go-w wordmatic

…and we can add write and execute permission to the second file for all users with:

   chmod a+wx calcmatic

Copying Permissions

As one other shortcut, it’s possible to tell chmod “give users of one class the same permissions that some other class has.”

Let’s say we have these files:

d------rwx  joe  acctg  sales
-rw-r--r--  joe  acctg  info.dat

The other users have full permissions on the sales directory. We’d like to say “ the user and group should be assigned (=) the permissions belonging to others.” That translates to:

   chmod ug=o

Similarly, to make info.dat readable and writable to the group, we can say:

   chmod g=u info.dat

(you can read this as “the group is assigned (=) the permissions currently held by the user.”)

You may also use + and – to add and subtract the permissions that currently belong to a different class of user.

You can’t mix the standard permissions (r, w, and x) with the coyping shortcuts. chmod will protest if you give it something like this:

   chmod g=wu info.dat

Taken from http://catcode.com/teachmod/chmod_cmd.html


4) umask = set file creation mask

The ‘UMASK‘ is the default permission setting that is applied to your files and directories when they are created. After files and directories are created, the chmod command can be used to change the permissions to allow or disallow access as before. The UMASK is set when you login to a UNIX machine.

It is, however, possible to change your UMASK and put the UMASK in your login files so that your default permissions are always set for files when you create them.

Just like chmod, a umask works on a number. However, instead of the numbers being ADDED like chmod, with a umask the numbers are SUBTRACTED from 7.

So from chmod –

Read – 4
Write – 2
Execute – 1

If a user wants all directories to be created with rwxr-xr-x, that is

Owner == Read, Write, Execute == 7 – 4 – 2 – 1 == 0
Group == Read, Execute == 7 – 4 – 1 == 2
Others == Read, Execute == 7 – 4 – 1 == 2

Then the umask would be 022

There is one important difference with the UMASK and files and directories – the execute part will be set on directories, but they have to be manually changed on files after the file has been created. The read and write parts remain the same.

You can change your default UMASK using the command ‘umask’. For example, the command:

umask 022

Will change your umask to the permissions stated above.

To make your new umask be the default for your next login, you will have to edit your .login file and place the umask command down the bottom of that file. The next time you login to your UNIX system, your default umask will be set to that which you have specified in your .login file.

For redhat, to change permanently modify .bashrc and include umask nnn in one of the lines.

1) find = finds one or more files assuming that you know their approximate filenames


find -name mypage.htm
In the above command the system would search for any file named mypage.htm in the current directory and any subdirectory.

find / -name mypage.htm
In the above example the system would search for any file named mypage.htm on the root and all subdirectories from the root.

find -name file*
In the above example the system would search for any file beginning with file in the current directory and any subdirectory.

find -name ‘*’ -size +1000k
In the above example the system would search for any file that is larger then 1000k.

find /usr -name *stat

Find every file under the directory /usr ending in “.stat”.

find / -mtime -2 -print

Search the system for files that were modified within the last two days (good candidates for backing up)

More examples: http://www.oracle.com/technology/pub/articles/calish-find.html


2) locate = find files by name

Searches are conducted against a database of system contents that is updated periodically. To update the database, use the updatedb command.

locate "*.png"

to display all files on the system that have the .png filename extension

locate "*.png" -q

to suppress error messages, such as those that might be returned in the event that the user does not have permission to access designated files or directories

locate -n 15 "*.html"

display only 15 results in a search for files that have an .html extension:

locate "*.html" | less

presents only one screenful of output at a time

locate -i "*.HtmL"

The -i option performs a case-insensitive search. That is, it will return any results that match the arguments regardless of whether individual letters are lower case or upper case.


3) whereis = the whereis command is used to locate the binary, the source code and the online manual page for any specified program. Take note it is not for searching your files.


whereis locate

locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz

whereis -b locate (search only binaries)

locate: /usr/bin/locate


4) sort =  sort lines of text files

sort can be used in many ways, below are some simple examples

a) example 1

assume i have 1 text file with name fruits containing below


and another text file veggy with contents below


sort fruits veggy : it will produce output in alphabetical order as below


sort fruits veggy > fruitveggy : this command will save into a file fruitveggy

b) example 2

i can create a text file that is sorted in real time, for example, by typing

sort > color

it will put me into data entry mode, i can keep entering data for example blue, green, yellow each followed by <enter> command. once im done, pressing Ctrl-D keep me back at command prompt. now if i check the text file color i can see alll my input is there already sort out

c) example 3

i have a data file data.txt as below:

24 John
45 Sharon
98 Robert

i want to sort it on second field (name by alphabetical order), i can use this command

sort -d -k 2 data.txt , the output will be

24 John
98 Robert
45 Sharon

Explanation: The ‘-d’ switch stands for ‘dictionary sort’ and ensures that sorting

takes place alphabetically as a dictionary would do it. The ‘-k’ switch

stands for ‘key’ and with the ‘2’ tells sort to sort on the second

field in the file, that is the names.


5) grep = finds text within a file

grep tutorial *.htm = search all .htm files in the current directory for the text “tutorial”

grep -i love history.txt = print all lines containing love (ignoring uppercase and lowercase) in history.txt

grep -ic “love me” history.txt = To print just the number of lines containing the word “love me”

grep -r tutorial * = -r is to search not only in the current directory but recursively in all the sub directories, the symbol * means to search all files

ls | grep readme = this command is to print all files that has the phrase “readme” in the filename. take note it is not the text inside the document but the name of the document

ls -l | grep rwxrwxrwx = to find all filesystem objects in the current directory whose permissions have been set so that any user can read, write and execute them

1) more = to view a text file one page at a time, press spacebar to go to the next page

more filename : show the document one page at a time

more -num filename : show the document page few lines as specified bu (-num)

example : more -10 filename will show 10 lines for every page


2) less = is much the same as more command except:

a) You can navigate the page up/down using the less command and not possible in more command.

b) You can search a string in less command. (use /keywordto search)

c) “more” was fairly limited, and additional development on “more” had stopped

d) it uses same functions as vi editor

the usage : less filename


3) head = displays the first ten lines of a file, unless otherwise stated.


head myfile.txt – Would display the first ten lines of myfile.txt.

head -15 myfile.txt – Would display the first fifteen lines of myfile.txt.


4) tail = display the last part of the file

usage : tail filename

tail -n filename : display the last n lines of the file


5) cat = can be used to join multiple files together and print the result on screen (it will not show page by page)


cat 01.txt
to displat the contents of file 01.txt

cat 01.txt 02.txt
to display the contents of both files

cat file1.txt file2.txt > file3.txt – Reads file1.txt and file2.txt and  combines those files to make

cat note5 >> notes – attach note5 to notes

cat >> file1 – add additional data in file1