[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 2

du Command

Purpose

Summarizes disk usage.

Syntax

du [ -a | -s ] [ -k ] [ -l ] [ -r ] [ -x ] [ File ... ]

Description

The du command displays the number of blocks used for files. If the File parameter specified is actually a directory, all files within the directory are reported on. If no File parameter is provided, the du command uses the files in the current directory.

Specifying the -a flag reports the number of blocks in individual files. Whether the -a flag is used or not, individual files specified by the File parameter are always listed.

Specifying the -s flag reports the total blocks for all specified files or all files in a directory.

The block count includes indirect blocks of each file. Block count is calculated in 512-byte units independent of the cluster size used by the system. Specifying the -k flag calculates the block count in 1024-byte units.

Notes:
  1. Files with multiple links are counted and written for only one entry.
  2. Block counts are based only on file size; therefore, unallocated blocks are not accounted for in the reported block counts.

Flags

-a Displays disk usage for each file specified, or displays the individual disk usage for each file in a directory. Contrast this flag with the -s flag.
-k Calculates the block count in 1024-byte units rather than the default 512-byte units.
-l Allocates blocks evenly among the links for files with multiple links. By default, a file with two or more links is counted only once.
-r Reports names of inaccessible files and directories. This is the default.
-s Displays the total disk usage for all specified files, or displays the total disk usage for all files in a directory. Contrast this flag with the -a flag.
-x When evaluating file sizes, evaluates only those files that reside on the same device as the file or directory specified by the File parameter. For example, you may specify a directory that contains files on several devices. In this case, the -x flag displays block sizes for all files that reside on the same device as the directory.

Exit Status

This command returns the following exit values:

0 Successful completion.
>0 An error occurred.

Examples

  1. To summarize the disk usage of a directory tree and each of its subtrees, enter:
    du   /home/fran
    This displays the number of disk blocks in the /home/fran directory and each of its subdirectories.
  2. To display the disk usage of each file, enter:
    du     -a     /home/fran
    This displays the number of disk blocks contained in each file and subdirectory of the /home/fran directory. The number beside a directory is the disk usage of that directory tree. The number beside a regular file is the disk usage of that file alone.
  3. To display only the total disk usage of a directory tree, enter:
    du -s     /home/fran
    The -s flag instructs the du command to display only the sum total disk usage of the /home/fran directory and the files it contains. By default, the du command displays an error message if it cannot read a file or directory.

Files

/usr/bin/du Contains the du command.

Related Information

The df command.

The Directory Overview in AIX Version 4.3 System User's Guide: Operating System and Devices explains working with directories and path names.

The Files Overview in AIX Version 4.3 System User's Guide: Operating System and Devices provides information on working with files.


[ Previous | Next | Contents | Glossary | Home | Search ]