The first lab session of my Computer Science course consisted primarily of learning the following Unix commands:
man. Although I’ve been using nothing but Windows throughout my career – from Windows 95 to 2000 to XP – these commands have proven to be indispensible for those occasions when I need to remotely administer a Linux box.
Let’s go through them one by one.
You log in to a Linux server and all you get is a dollar sign and a cursor. The first thing you want to know is: where am I? So you want to print the working directory:
Then you want to list all the contents of the current directory in a long listing format:
To get around, you change directory:
Then, to copy a file from one directory to another:
cp /some/directory/somefile.txt /another/directory
To move it instead:
mv /some/directory/somefile.txt /another/directory
There is no command to rename, you just move it:
mv oldname.txt newname.txt
To remove a file:
To remove a directory and its contents recursively:
rm -r dirname (use with extreme caution!)
To make a directory:
To change the mode of a file or directory to make it writeable by everyone:
chmod ugo+rwx file_or_directory
ugo+rwx means, for (user, group, others), add (read, write, execute) permissions. Use the minus sign instead of the plus sign to remove permissions.
rwx can be used in any combination, e.g.,
Finally, to get to know more about the contents of a file:
Press space to scroll to the next page, and q to quit. (Note:
less is better than
less, you could go both backwards and forwards.)
Finally: when in doubt, consult the manual!
Update 13 February 2009
See also Commands that you must know in Linux… by dirn.name.
and i want to add about vi command..it’s a must !! as well as other commands such as ps, grep, netstat, ping, traceroute, sudo, scp, ifconfig, who and other commands
Thats a great list, I’m just getting into Unix so that will come in handy.
[…] again. So to read the file, you can go to second tab and open it there by using less (thanks Rizal) […]
Here is the Ying to your Yang: http://www.thegeekstuff.com/2009/02/four-useless-linux-commands/
Nice post, straight to the point.
Nice Blog, Thanks for the simple Unix commands… I all of a sudden got some interest in learning some unix commands on my MAC after i went through your above post… 🙂