Very Useful Linux/Unix Commands
Working on a *nix system is no piece of cake. Especially when you are used to Graphic interface of ‘windows’. The world where mouse is the king.
Here is a list of most used / most discussed / most important *nix commands. Mastering this will surely get your confidence level high in the black background and white characters’ world !!
My experience says that for starters in UNiX / LiNuX , these commands are enough to get you in smoothly !
clear
Clears the terminal window
usage: [root@test~]$ clear
ls
List contents of a directory
usage: [root@test~]$ ls usage: [root@test~]$ ls -l
cat
Displays the contents of a file in the terminal
usage: [root@test~]$ cat filename.extension
usage: [root@test~]$ rm filename.extension usage: [root@test~]$ rm -i filename.extension [prompts for confirmation before removing a file] usage: [root@test~]$ rm -f filename.extension [force removal of the file regardless of it bieng write-protected or open] usage: [root@test~]$ rm -r directory [remove files recursively in 'directory']
usage: [root@test~]$ cp file1.ext file2.ext usage: [root@test~]$ cp file1.ext /some/other/location/file2.ext usage: [root@test~]$ cp file1.ext user@some.other.server:~/some/other/location/file2.ext
usage: [root@test~]$ passwd usage: [root@test~]$ passwd SomeNewUser [root access only]
usage: [root@test~]$ motd
finger
User information lookup program
usage: [root@test~]$ finger -p Login Name Tty Idle Login Time Office Office Phone xuser pts/0 Oct 22 22:04 (ool-4578671d.dyn.optonline.net)
startx
Starts an X Window System server
usage: [root@test~]$ startx -dpi 300 -depth 32
less
Displays the contents of a file in the terminal one page at a time
usage: [root@test~]$ less filename.ext usage: [root@test~]$ less +G filename.ext [start from end]
info
Displays information and documentation on shells, utilities and programs
usage: [root@test~]$ info usage: [root@test~]$ info less
usage: [root@test~]$ lpr filename.ext usage: [root@test~]$ lpr -# 3 filename.ext [3 copies]
grep
looks through files for strings
usage: [root@test~]$ grep "needle" haystack.ext usage: [root@test~]$ grep -i "neEdlE" haystack.ext usage: [root@test~]$ grep -i -r "neEdlE" directory/
head
Displays first 10 lines of file
usage: [root@test~]$ head filename.ext
tail
Displays last 10 lines of file
usage: [root@test~]$ tail filename.log usage: [root@test~]$ tail -f filename.log [don't exit // realtime]
usage: [root@test~]$ mv filename.ext /some/other/directory/ usage: [root@test~]$ mv filename.ext newname.ext [rename]
file
Displays information about file contents
usage: [root@test~]$ file program.php program.php: PHP script text usage: [root@test~]$ file archive.tar.gz archive.tar.gz: gzip compressed data, from Unix
echo
Copies string to terminal
usage: [root@test~]$ echo Hello Think-Lamp usage: [root@test~]$ echo * | wc
date
Displays current date and time
usage: [root@test~]$ date usage: [root@test~]$ date -R
usage: [root@test~]$ cal usage: [root@test~]$ cal -y 2009
usage: [root@test~]$ gzip filename.etx > archive.gz usage: [root@test~]$ gzip -f -q filename.etx > archive.gz[force and supress errors] usage: [root@test~]$ gzip -f -q -r directory/ > archive.gz
gunzip
Decompresses a compressed file
usage: [root@test~]$ gunzip archive.gz
which
Displays path to command
usage: [root@test~]$ which echo usage: [root@test~]$ which less
whereis
Displays paths to locations of commands
usage: [root@test~]$ whereis echo usage: [root@test~]$ whereis less
who
Lists currently logged on users
usage: [root@test~]$ who usage: [root@test~]$ who -b
w
Lists currently logged on users with processing usage
usage: [root@test~]$ w
mesg
Sets options for letting other users write you messages
usage: [root@test~]$ mesg
write
Sends message to other users
usage: [root@test~]$ write xuser hello! This is test message usage: [xuser@test~]$ Message from [root@test~]$ on pts/1 at 13:25 ... hello! This is test message
talk
Allows two way chat to other users
usage: [root@test~]$ talk xuser@test usage: [xuser@test~]$ Message from root@test talk: connection requested by root@test. talk: respond with: talk xuser@test
chmod
Changes file access permissions
usage: [root@test~]$ chmod 775 file.ext usage: [root@test~]$ chmod -r 777 directory/ CHMOD can also to attributed by using Numeric Permissions: 400 read by owner 040 read by group 004 read by anybody (other) 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybody ____ 777 read/write/execute by everybody !
usage: [root@test~]$ mkdir newdirectory
rmdir
Removes an empty directory
usage: [root@test~]$ rmdir newdirectory
ln
Creates link to an existing file [hard, soft]
usage: (hard link) [root@test~]$ ln targetfile.ext linkname.ext usage: (soft link) [root@test~]$ ln -s targetfile.ext linkname.ext
df
Displays all mounted filesystems
usage: [root@test~]$ df usage: [root@test~]$ df -h
top
Displays updating list of currently running processes
usage: [root@test~] top # Once in TOP screen, use shift+F to select 'sort by' field. # Once in Top screen, use Shift+R to 'sort' ascending OR descending
tty
Displays the name of the terminal in which the command was issued
usage: [root@test~] tty
kill
Aborts a process by PID (Process Identification Number) or job number
usage: [root@test~] kill -p 2345
jobs
Displays a list of current jobs
usage: [root@test~] jobs usage: [root@test~] jobs -l
netstat
Displays network connections
usage: [root@test~] netstat -a -e
Tags: cli, commands, Linux, linux commands, unix commands
6 Comments
Comments RSS
TrackBack Identifier URI
Leave a comment
Hi this page is not working properly in Google Chrome and Fire Fox
Please check it
Comment by Dara Ramu on November 20, 2008 5:37 am
it works fine in Chrome
Comment by nimishat on November 24, 2008 2:18 am
He’s using Linux so he’s using Gecko or Webkit browser at most
anyway it’s working fine from FF
Comment by Amaiko on November 26, 2008 12:55 pm
“… this page is not working properly..”
Seriously? That’s all you can say to help? Why not tell them exactly what’s “not working properly”?
Comment by Hugh Jardon on November 30, 2008 3:07 am
thanks a lot,now its easy 2 work on linux
Comment by ranjeet on December 5, 2009 12:00 am
these are really helpful
Comment by Sonu giri @ iit punjab cse on August 10, 2010 2:35 pm