Previous | Table of Contents | Next |
DESCRIPTION
The external du command is used to find out how much disk space is used in a directory structure. By using the du command you can:
The du command is somewhat of a counterpart to the df command. The df informs you that you are low on space. The du command tells you which files are using the most disk space.
If you do not provide any options or arguments, du displays the number of blocks contained in each file or subdirectory. All files in all subdirectories are added and displayed as one summary for each directory.
If a file is a link, it is only displayed once.
COMMAND FORMAT
Following is the general format of the du command.
du [ -rs ] [ directory_list ] du [ -ars ] [ file_list directory_list ]
Options
The following options may be used to control how du functions.
-a | Allows the use of filenames instead of just directory names . |
-r | Returns a message for files that cannot be read or opened. Usually, du ignores files it cannot read or open . It does not mention them or estimate their size . |
-s | Summary listing. Displays only the totals for specified directories. If the -a option is used, totals for files are given. If no options are given, du displays the size of each subdirectory in blocks. |
|
---|
BSD (Berkeley) |
The BSD version of du does not support the -r option. |
|
Arguments
The following arguments may be passed to the du command.
directory_list | One or more directories are searched and the size of each file or subdirectory is displayed. |
file_list | One or more files are read and the file size displayed. If no arguments are provided, the current directory (.) is used as an argument. |
DIAGNOSTICS AND BUGS
The du command does not display any information about files that it cannot read or open. If you do not specify the -a option, du ignores filenames given in its argument list. If links span across unrelated directories, then the file is counted for each occurrence of a link.
RELATED COMMANDS
Refer to the df command described in Module 32.
APPLICATIONS
Use the du command to check which directories are using most of your disk space. If you are running low on space and need to remove files, the du command provides a means of locating where the bulk of your file space is being used.
As a user you can search your own directories for large files and subdirectories. The system administrator can use du to locate users that are using large amounts of disk space.
Once you locate the unwanted files, use the rm command to discard the files and recover the file space. You may wish to archive the files with the cpio or tar commands before removing them.
TYPICAL OPERATION
In this activity you use the du command to display the disk space you are currently using. Begin at the shell prompt.
cj du 4 ./letters 2 ./bin 8 ./db 28 .
Previous | Table of Contents | Next |