UNIX Tutorial Six

Other useful UNIX commands  

df

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

$ df .

du

The du command outputs the the amount disk space used by each subdirectory. This is useful if you need to free some space on your disk and you want to find out which directory is taking up the most space. In your home-directory, type

$ du

This is likely to be a very long list if you have many nested directories. You can control how the depth of the listing with the -d switch. To see one directory deep type

$ du -d 1

zip

This compresses a file or set of files and reduces the amount of disk space they take. For example, type

$ ls -l science.txt

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

$ zip science science.txt

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

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

To uncompress the file, use the unzip command.

$ unzip science.txt.zip

You can compress several files into one zip file by using wild cards. You can also zip entire directories. This can be very useful when you need to collect files to another user. Using the zip command is identical to compressing files by selecting Compress from the File menu in the Finder.

file

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 *

history

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)

 

Adapted for Mac OS X by Shane Burns from a tutorial by M.Stonebank@surrey.ac.uk, © 24th August 2001