Solaris Advanced User's Guide

Managing Disk Storage

Because space on the disk is a limited resource, make sure that you know the amount of space currently in use.

Displaying Disk Usage (df -k)

The df -k command displays the amount of space currently in use on each disk mounted (directly accessible) to your system. For the capacity of each disk mounted on your system, the amount of space available, and the percentage of space in use, use the df -k command.


$ df -k

If the output of the df -k command indicates your file systems are at or above 90 percent capacity, clear unnecessary files. Clear the files by moving them to a disk or tape, using cp to copy files and mv to move them, or removing files with the rm command. Perform these kinds of “housekeeping” chores only on files that you own.

Displaying Directory Usage (du)

You can use du to display the usage of a directory and all its subdirectories in units of 512 bytes or characters.

du shows you the disk usage in each subdirectory. For a list of subdirectories in a file system, change the directory to the path name that is associated with that file system. Then run the following pipeline:


$ du | sort -r -n

This pipeline, which uses the reverse (-r) and numeric (-n) options of the sort command, identifies large directories. Use ls -l to examine the size (in bytes) and modification times of files within each directory. Old files and text files larger 100 KBytes might warrant storage offline.