System Administration Guide, Volume 2

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

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 you specify, including each subdirectory beneath it. 

-a

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

-s

Displays only the total number of blocks contained in the specified directory. 

directory ...

Specifies one or more directories you want to check. 

Examples--Displaying the Size of Directories, Subdirectories, and Files

The following example displays the total sizes of two directories and all the subdirectories they contain.


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

The following example displays the sizes of two directories, all of the subdirectories and files they contain, and the total number of blocks contained in each directory.


$ du /var/adm /var/spool/lp
2       /var/adm/log
2       /var/adm/passwd
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
130     /var/adm
4       /var/spool/lp/admins
2       /var/spool/lp/fifos/private
2       /var/spool/lp/fifos/public
6       /var/spool/lp/fifos
2       /var/spool/lp/requests/starbug
4       /var/spool/lp/requests
2       /var/spool/lp/system
2       /var/spool/lp/tmp/starbug
2       /var/spool/lp/tmp/.net/tmp/starbug
4       /var/spool/lp/tmp/.net/tmp
2       /var/spool/lp/tmp/.net/requests/starbug
4       /var/spool/lp/tmp/.net/requests
10      /var/spool/lp/tmp/.net
14      /var/spool/lp/tmp
40      /var/spool/lp