UNIX Tutorial Six

Other useful UNIX commands  


The df command reports on the space left on the file system. For example, to find out how much space is left on the fileserver, type

% df .

The df command without the "." will list the remaining space on all currently mounted file systems.


The du command outputs the number of kilobyes used by each subdirectory. Useful if you want to find out which directory consumes the most storage. In your home-directory, type

% du


Note: The compress command has been made obsolete by a program named gzip. For this reason, compress might not be installed on your system. But, if it is available, you can try the following:

The compress command reduces the size of a file (without any loss of information) thus freeing valuable disk space. For example, type

% ls -l science.txt

and note the size of the file. Then to compress science.txt, type

% compress science.txt

This will compress the file and place it in a file called science.txt.Z

To see the change in size, type ls -l again.

To uncomress the file, use the uncompress command.

% uncompress science.txt.Z


This also compresses a file, and is more efficient than compress. For example, to gzip science.txt, type

% gzip science.txt

This will gzip the file and place it in a file called science.txt.gz

To unzip the file, use the gunzip command.

% gunzip science.txt.gz


file classifies the named files according to the type of data they contain, for example ascii (text), pictures, compressed data, etc.. To report on all files in your home directory, type

% file *


The C shell keeps an ordered list of all the commands that you have entered. Each command is given a number according to the order it was entered.

% history (show command history list)

If you are using the C shell, you can use the exclamation character (!) to recall commands easily.

% !! (recall last command)

% !-3 (recall third most recent command)

% !5 (recall 5th command in list)

% !grep (recall last command starting with grep)

You can increase the size of the history buffer by typing

% set history=100

Continue with the Tutorial

M.Stonebank@surrey.ac.uk, © 24th August 2001