Wednesday, 18 May 2011

Useful UNIX Commands

man => list the help for command.
man -k => seraches for command.
whatis => gives the brief description of command
rm –r dirname => to remove the directory containg files.
vi file1 file2 file3 => to open multiple files
vi +10 filename => open the file at the cursor pointing to line no 10.
to move next file => :n
to move previous file => :e#
ls => list files (options –l for long, -a for all)
mv filename1 filename2 => rename filename1 with the name filename2 
cp filename1 filename2 => make a copy of filename1 and call it filename2
rm filename => delete filename
more filename => print contents of filename1 to the screen
cat filename => print contents of filename to the screen
cat filename1 >> filename2 => append contents of filename1 to the file filename2
cat part1 part2 >> bothparts  appends the contents of file part1 and file part2 to to the file bothparts
head filename => show first 10 lines to screen
tail filename => show last 10 lines to screen
pwd => show current directory
mkdir dirname => create new directory dirname
rmdir dirname => remove directory dirname
cd dirname => Change to directory dirname
* wildcard (matches any number of characters)
? wildcard (matches single character)
grep word filename => list lines of filename containing word
diff filename1 filename2 => shows differences between filename1 and filename2
wc filename  => counts number of lines, words, and characters in filename 
sort < filename => sorts the lines of filename
who => lists users currently on the system
cal => displays current month's calendar
date => displays date
du –s => Total kilobytes used in current directory
du –a => Same as above, but more detail
ls –l => Gives individual file sizes in bytes
Ctrl-c => Cancel a foreground job
Ctrl-z => Suspend a job in the foreground
bg  => Move a suspended foreground job to the background
ps –u  =>List information for processes you own (under current shell)
ps –ux  => Lists information for process owned by you and others
ps –aux  => Lists information for all processes (including root, bin, etc.)
ps –aux | more => Display output of ps –aux one page at a time
ps –aux | grep PID => List lines from command ps –aux containing PID
kill PID => Kills (cancels) process number PID
top => Lists 15 processes using the most cpu processing power
q   => Stops command top
ls -F => differentiate the files and directory

No comments:

Post a Comment