1) su = become super user or another user

Examples:

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

Examples:

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

Examples:

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

username:password:userid:groupid:userdirectory:usershell
or
antony:x:103:105:/home/antony:/bin/sh

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

Examples:

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