System Administration Guide: Advanced Administration

ProcedureHow to Display the Size of Directories, Subdirectories, and Files

  1. Display the size of one or more directories, subdirectories, and files by using the du command. Sizes are displayed in 512-byte blocks.


    $ du [-as] [directory ...]
    du

    Displays the size of each directory that you specify, including each subdirectory beneath it.

    -a

    Displays the size of each file and subdirectory, and the total number of blocks that are contained in the specified directory.

    -s

    Displays the total number of blocks that are contained in the specified directory.

    -h

    Displays the size of each directory in 1024–byte blocks.

    -H

    Displays the size of each directory in 1000–byte blocks.

    [directory ...]

    Identifies one or more directories that you want to check. Separate multiple directories in the command-line syntax with spaces.


Example 6–9 Displaying the Size of Directories, Subdirectories, and Files

The following example shows the sizes of two directories.


$ du -s /var/adm /var/spool/lp
130     /var/adm
40      /var/spool/lp

The following example shows the sizes of two directories and includes the sizes of all the subdirectories and files that are contained within each directory. The total number of blocks that are contained in each directory is also displayed.


$ du /var/adm /var/spool/lp
2       /var/adm/exacct
2       /var/adm/log
2       /var/adm/streams
2       /var/adm/acct/fiscal
2       /var/adm/acct/nite
2       /var/adm/acct/sum
8       /var/adm/acct
2       /var/adm/sa
2       /var/adm/sm.bin
258     /var/adm
4       /var/spool/lp/admins
2       /var/spool/lp/requests/printing....
4       /var/spool/lp/requests
4       /var/spool/lp/system
2       /var/spool/lp/fifos
24      /var/spool/lp

The following example shows directory sizes in 1024–byte blocks.


$ du -h /usr/share/audio
 796K   /usr/share/audio/samples/au
 797K   /usr/share/audio/samples
 798K   /usr/share/audio