You are on page 1of 7

Linux Commands

(These cmds r exec on my terminal try it)
To set/display terminal characterstics vishal@vishal-desktop:~$ stty speed 38400 baud; line = 0; eol = M-^?; eol2 = M-^?; swtch = M-^?; ixany iutf8 --to see all vishal@vishal-desktop:~$ stty -a speed 38400 baud; rows 24; columns 80; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke --to change vishal@vishal-desktop:~$ stty kill \^k vishal@vishal-desktop:~$ stty -a speed 38400 baud; rows 39; columns 125; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^K; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke To check for login details of users vishal@vishal-desktop:~$ who vishal tty7 2009-11-17 20:19 (:0) vishal pts/0 2009-11-17 20:37 (:0.0) --for heading vishal@vishal-desktop:~$ who -H NAME LINE TIME COMMENT vishal tty7 2009-11-17 20:19 (:0) vishal pts/0 2009-11-17 20:37 (:0.0) --for more detail vishal@vishal-desktop:~$ who -Hu NAME LINE TIME IDLE

PID COMMENT

print name of current/working directory vishal@vishal-desktop:~$ pwd /home/vishal To display calender --by default current vishal@vishal-desktop:~$ cal November 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 --fro perticular mnth n yr vishal@vishal-desktop:~$ cal 03 2009 March 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 . 2852 (:0) 3983 (:0.vishal tty7 vishal pts/0 2009-11-17 20:19 old 2009-11-17 20:37 .0) --to chk datentime of last boot vishal@vishal-desktop:~$ who -b system boot 2009-11-17 20:19 To chk device name u r using vishal@vishal-desktop:~$ tty /dev/pts/0 To print/set date vishal@vishal-desktop:~$ date Tue Nov 17 21:04:38 IST 2009 --options to set are date -t date -u $pwd .

--for perticular yr vishal@vishal-desktop:~$ cal 2009 2009 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14 11 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21 18 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28 25 26 27 28 29 30 31 29 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 2 1 2 3 4 5 6 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13 12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20 19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30 31 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 4 1 1 2 3 4 5 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 30 31 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12 11 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26 25 26 27 28 29 30 31 29 30 27 28 29 30 31 To display process info --to chk for current shell id vishal@vishal-desktop:~$ echo $$ 3985 --for general current process info vishal@vishal-desktop:~$ ps PID TTY TIME CMD 3985 pts/0 00:00:00 bash 4861 pts/0 00:00:00 ps --list full(-f option) bgrnd & active processes vishal@vishal-desktop:~$ ps -f UID PID PPID C STIME TTY TIME CMD vishal 3985 3983 0 20:37 pts/0 00:00:00 bash vishal 4863 3985 0 21:15 pts/0 00:00:00 ps -f .

] PID(s) //in linux der r 32 signal each perform individual tasks for perticular proc u can chk pid by $ps currently running eg:$kill 105 #it will terminate proc with PID 105 to send perticular process in background “&” is used to kill bg proc Eg.0 1.sf.-$nice wc vish.echo "1 min is over" 1 min is over #after 1 min it show this msg $wait [PID] #wait 4 completion of bgrnd proc .net/faq. perhaps a bogus '-'? See http://procps.5 2768 1032 pts/0 R+ 21:18 0:00 ps -u --display process of all user(on network-here it show only urs) vishal@vishal-desktop:~$ ps -a PID TTY TIME CMD 4933 pts/0 00:00:00 ps --display system proc vishal@vishal-desktop:~$ ps -e (list all system processes of ur m/c) To terminate process syntax $kill [signal no.--display prc of user vishal@vishal-desktop:~$ ps -u Warning: bad ps syntax.$sort -o stud stud1 & 345 (it will sort stud file and put it in stud1 in background and return PID of proc) to kill bg proc cmd is $! eg:-kill $! (kill sort proc) $kill 0 (will terminate all proc except shell) To perform process sheduling --to change priority(range from 0(high)-120(low)-20 is normal) syntax: $nice [priority] command [arguments] Eg.0 0.txt (it will reduce priorty of prc) To susoend exec of script vishal@vishal-desktop:~$ sleep 60.html USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND vishal 3985 0.6 6320 2988 pts/0 Rs 20:37 0:00 bash vishal 4931 0.

append a file vishal@vishal-desktop:~$ cd Desktop/ vishal@vishal-desktop:~/Desktop$ mkdir Vishal vishal@vishal-desktop:~/Desktop$ cd Vishal/ --to create file vishal@vishal-desktop:~/Desktop/Vishal$ cat > vish.File oprations To create.txt vishal@vishal-desktop:~/Desktop/Vishal$ cat v1.txt --display file cntnts vishal@vishal-desktop:~/Desktop/Vishal$ cat v1.display.tx This is placed in vishal folder(after typing content press ctrl+d to stop inputing) --to display vishal@vishal-desktop:~/Desktop/Vishal$ cat vish.tx This is placed in vishal folder Hi myself Vishal I m creating vish.tx This is placed in vishal folder --to copy in other file if not there create new vishal@vishal-desktop:~/Desktop/Vishal$ cat vish.txt 1 Hi myself Vishal 2 I m creating vish.txt Hi myself Vishal I m creating vish.txt (aftre u press enter it will start tkng ip) Hi myself Vishal I m creating vish.copy.txt Hi myself Vishal I m creating vish.tx 3 This is placed in vishal folder .tx This is placed in vishal folder --to append vishal@vishal-desktop:~/Desktop/Vishal$ cat vish.concat.tx This is placed in vishal folder --to number vishal@vishal-desktop:~/Desktop/Vishal$ cat -n vish.txt >v1.txt>>v1.txt Hi myself Vishal I m creating vish.

txt vish.1 vishal vishal 138 2009-11-17 22:09 v1.tx v1.tx v1.txt vishal@vishal-desktop:~/Desktop/Vishal$ mv v1.tx vish.tx v1.Listing file/dir vishal@vishal-desktop:~/Desktop/Vishal$ pwd /home/vishal/Desktop/Vishal --to list vishal@vishal-desktop:~/Desktop/Vishal$ ls v1.txt --list full file(dir/executable etc) //use -d for directory vishal@vishal-desktop:~/Desktop/Vishal$ ls -f vish.txt --list all hiddenalso vishal@vishal-desktop:~/Desktop/Vishal$ ls -a .txt --list horizontly vishal@vishal-desktop:~/Desktop/Vishal$ ls -x v1.txt v1.1 vishal vishal 69 2009-11-17 22:01 vish.tx v1.txt --long detailed listing vishal@vishal-desktop:~/Desktop/Vishal$ ls -l total 12 -rw-r--r-. v1.txt vish vish..txt vish/v moving/renaming file vishal@vishal-desktop:~/Desktop/Vishal$ ls v1.tx .1 vishal vishal 69 2009-11-17 22:09 v1.txt --list alphabetically vishal@vishal-desktop:~/Desktop/Vishal$ ls -c //use -r to reverse sort v1.tx vish. v1.doc vish.tx -rw-r--r-.txt vish vish.2nd perm is for group.txt vish..doc vishal@vishal-desktop:~/Desktop/Vishal$ ls v1.txt vish.3rd perm is for others Changing directories $cd [path] //if path not given place u at ur home dir copying vishal@vishal-desktop:~/Desktop/Vishal$ cp vish.txt -rw-r--r-.txt .txt vish vish. v1. .txt .txt Setting/changing file attributes vishal@vishal-desktop:~/Desktop/Vishal$ ls v1.doc vish.txt r-read permission w-write x-exec 1st perm is for user.

doc -rwxr--r-.vishal@vishal-desktop:~/Desktop/Vishal$ ls -l vish.1 vishal vishal 69 2009-11-17 22:09 vish.doc --exec to all(-a) vishal@vishal-desktop:~/Desktop/Vishal$ chmod a+x vish.doc --giv exec per to user/owner(-u(user)-g(group)-o(other)(+=add -=remove)) vishal@vishal-desktop:~/Desktop/Vishal$ chmod u+x vish..1 vishal vishal 69 2009-11-17 22:09 vish.doc -rwxr-xr-x 1 vishal vishal 69 2009-11-17 22:09 vish.doc vishal@vishal-desktop:~/Desktop/Vishal$ ls -l vish.) .doc -rw-r--r-.doc Setting/changing file ownership syntax: $chown newowner filename Setting/changing file group $chgrp group filename (Further useful cmds and scripts will be uploaded soon.doc vishal@vishal-desktop:~/Desktop/Vishal$ ls -l vish..