University of Pretoria
Operational / Internal Site

Unix Commands Summary

The following is a very brief summary of typical Unix commands.

For more detailed information about Linux (and numerous other topics), please see the documentation available under /afs/ The “Rute Users Tutorial and Exposition” is highly recommended for new Unix users (particularly chapters 4, 6, 7, 9, 12 and 14). The Rute tutorial is available in the given directory and at, as well as numerous other sites (do a google search).

In general, if you want to find the program / command to perform a specific operation, you can use the “apropos” command. For example, to find the commands to list directors, use “apropos directory”. Alternatively, if you know the first few letters of a command, you can automatically complete and/or show available options by pressing TAB twice immediately after the first few letters (also known as command completion).

For more information about a command, use the “man” command. For example, to find out how the “ls” command works (for listing directories), do “man ls”.

Files and Directories

  • ls — lists files
    • ls -l — lists files in 'long format', which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.
    • ls -a — lists all files, including the ones whose filenames begin in a dot, which you do not always want to see.
    • There are many more options, for example to list files by size, by date, recursively etc.
  • mv srcfilename dstfilename — moves or renames a file or directory
  • cp srcfilename dstfilename — copies a file
  • rm filename — removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything.
  • diff filename1 filename2 — compares files, and shows where they differ.
  • wc filename — tells you how many lines, words, and characters there are in a file


  • mkdir dirname — make a new directory
  • cd dirname — change directory. You basically 'go' to another directory, and you will see the files in that directory when you do 'ls'. You always start out in your 'home directory', and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level up from your current position. You don't have to walk along step by step - you can make big leaps or avoid walking around by specifying pathnames.
  • pwd — tells you where you currently are.

Processes and Memory

If a cluster machine seems slow, check if there are computationally intestive programs running. The top, w, ps, and pstree commands can be helpful.

  • ps -u yourusername — lists your processes. Contains lots of information about them, including the process ID, which you need if you have to kill a process. Normally, when you have been kicked out of a dialin session or have otherwise managed to get yourself disconnected abruptly, this list will contain the processes you need to kill. Those may include the shell (tcsh or whatever you're using), and anything you were running, for example emacs or elm.
  • kill PID — kills (ends) the processes with the ID you gave. This works only for your own processes, of course. Get the ID by using ps. If the process doesn't 'die' properly, use the option -9. But attempt without that option first, because it doesn't give the process a chance to finish possibly important business before dying.

The free command can be used to tell you if you're running low on memory; the df command can tell you if you're running low on disk space, and the du command can tell you which files and directories are taking up space.