A quick introduction to Unix –– the top ten most useful commands

Users who are already familiar with Linux/Unix and the vi or emacs editors will need to read no further. Users who have little or no experience of Unix, and are keen to get started are advised to spend a few moments looking through this document. A brief synopsis of these "top ten most useful commands" is available see here.

There are many ways to create and edit files in Unix. If you do not have any previous experience of using command line editors in Linux you will probably want to use the emacs or gedit text editors to modify files. The command emacs my_file displays a new window in which you can view and modify the contents of the text file my_file in an intuitive manner, without having to know anything about the many more powerful capabilities of advanced emacs use.  (Note that you must be able to display new windows back to your local system - see our page on displaying a GUI. If you want to use a simple command-line editor in your original login window then nano is a good choice.)

To list which files and subdirectories you have in a directory use the ls command. (Directories are the equivalent of windows folders.) When you first log on to a Unix machine you are in your home directory.

To view or search the contents of the text file some_file use the command less some_file. To learn how to move around in the file or search with less type the letter "h" for help while in less.

To delete the file, some_file, use the command rm some_file.

Use the mkdir command to create a new directory, eg. mkdir new_dir to create a directory called new_dir. To change the directory use the cd command, eg. cd new_dir. Two dots are used to represent the directory above, so cd .. will change to the directory above. The pwd command will show you where you are in the directory structure. It’s worth knowing that the command cd will always take you back to your home directory.

To delete the directory, new_dir, use the command rmdir new_dir. A directory must be empty before it can be deleted. To empty a directory use the rm command to delete it contents.

The mv command can be used to move or rename files. For example the command mv some_file new_dir moves the file some_file to the directory new_dir. The command mv some_file some_new_file renames the file some_file as some_new_file. You can move or rename a directory in exactly the same way as a file.

The cp command can be used to copy files. To make a copy of the file some_file in the directory new_dir use the command cp some_file new_dir.

Taking things further

Learn Unix in 10 minutes – a good reference/prompt document with more details. This is work in progress. This guide will be available soon.

Linux Fundamentals – An 86 page Unix/Linux training manual with lots of details