Your Ad Here

Linux Commands Tutorial

To work on linux one must be aware of few basic utilities linux provides. These utilities are in terms of commands. e.g. cd, ls, mv, etc. Following are some commands one must be aware of, to have good grasp over linux systems.

cal

Used to view the calender. cal 09 2009 shall show you the september 2009 month.

calendar

This shows the event occurence on the date and next date when you fired this command. You may also give date specific commands like calendar -t 10, which shows events of 10th and 11th of this month or calendar -t 10.10.2009 which shall show you the events of 10th october 2009 and 11th october 2009. Check if you have installed this utility. This may not be available on your system.

cat

cat is one of most used and very good command linux provides. To view any text file you'll use this in spite of numerous other commands to view a file. cat filename shall show you the file contents on standard output. You need to be careful while using this utility, as cat may hide few characters of the file or may show the contents in different encoding than that of the file.

cd

Meant for Change directory. One directory to another directory traversal is done by cd. by typing cd dirname you shall be in direname directory. Using cd - you shall move to the last directory where you came. cd .. shall move you to the parent directory.

cp

To copy a file or directory to another one. To copy the whole directory you may use cp -r fromDir toDir. -r is used for recursive operation.

cut

Its a very useful command to operate a file contents line by line. To do a operation on a file u need to separate the items by -d option and select the items by -f option. The default separator is tab(\t). The command can be used like cut -d ':' -f 1,2 filename. This shall operate on a file 'filename' selecting 1st and 2nd field whith separator as ':'.

du

du is another good utilty linux has. To get the disk usage of files and directories you may use the command du filename. Just typing du shall show you space taken by each child file and directory. So use -s option to get the summarized result. e.g. du -sh * shall show you the disk usage of each file and directory of current directory in human readable format.

factor

factor is a mathematical tool to get the factors of a number. Typing command factor 35 shall show you 35:5 7. This is used to get all the prime number a number constitutes of. Maximum value could be 18446744073709551615.

file

file is an utility to know the type of the file. Type file filename to get the type details of the file filename. e.g. file abc.txt may result abc.txt ASCII text. This can also give you the other encoding types like UTF-8 file and others.

head

head is used to show the lines of a file or any input stream. The good thing is that it is much faster than usual file viewer. head -15 filename shall show you the top 15 lines of the file filename. Default value is 10 lines.

less

less is a file viewer. It buffers as much data as needed to display. Therefore if you just need to view some files data less or more can help a lot. once you typed less filename, your file's content will be displayed and by pressing space button you can traverse the whole file. home and end buttons are used to reach at first line or last line of the file respectively. With command less, you don't need to worry about the type of file. zipped, gzipped files can also be viewed without unzipping. e.g. less file1.csv.gz is same as zcat file1.csv.gz|less