OpenWindows Advanced User's Guide

5.3 Managing Disk Storage

Since space on the disk is a limited resource, it is a very good idea to keep track of the space currently in use.

5.3.1 Displaying Disk Usage (df -k)

df -k shows you the amount of space currently in use on each disk that is mounted (directly accessible) to your system. Just type:

$ df -k

to see the capacity of each disk mounted on your system, the amount available, and the percentage of space already in use.

File systems at or above 90 percent of capacity should be cleared of unnecessary files. You can do this either by moving them to a disk or tape that is less full, using cp to copy them and rm to remove them, or you can simply remove them outright. Of course, you should only perform these kinds of "housekeeping" chores on files that you own.

5.3.2 Displaying Directory Usage (du)

You can use du to display the usage of a directory and all its subdirectories in 512-byte blocks; that is, units of 512 bytes or characters.

du shows you the disk usage in each subdirectory. To get a list of subdirectories in a filesystem, cd to the pathname associated with that filesystem, and run the following pipeline:

$ du | sort -r -n

This pipeline, which uses the reverse and numeric options of the sort command, pinpoints large directories. Use ls -l to examine the size (in bytes) and modification times of files within each directory. Old files, or text files over 100 Kbytes, often warrant storage offline.