System Administration Guide: Advanced Administration

Checking the Size of Directories

You can display the size of directories by using the du command and options. Additionally, you can find the amount of disk space used by user accounts on local UFS file systems by using the quot command. For more information about these commands, see du(1) and quot(1M).

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 the total number of blocks contained in the specified directory. 

-h

Displays the size of each directory in 1024 bytes. 

-H

Displays the size of each directory in 1000 bytes. 

directory ...

Identifies one or more directories you want to check. 

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

The following example shows the total 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, 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

The following example shows directory sizes in 1024 bytes.


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

How to Display the User Ownership of Local UFS File Systems

  1. Become superuser.

  2. Display users, directories, or file systems, and the number of 1024-byte blocks used.


    # quot [-a] [filesystem]

    -a

    Lists all users of each mounted UFS file system and the number of 1024-byte blocks used. 

    filesystem

    Identifies a UFS file system. Users and the number of blocks used are displayed. 


    Note –

    The quot command works only on local UFS file systems.


Example—Displaying the User Ownership of Local UFS File Systems

In the following example, users of the root (/) file system are displayed. Then, users of all mounted UFS file systems are displayed.


# quot /
/dev/rdsk/c0t0d0s0:
43340   root    
 3142   rimmer   
   47   uucp    
   35   lp      
   30   adm     
    4   bin     
    4   daemon  
# quot -a
/dev/rdsk/c0t0d0s0 (/):
43340   root    
 3150   rimmer  
   47   uucp    
   35   lp      
   30   adm     
    4   bin     
    4   daemon  
/dev/rdsk/c0t0d0s6 (/usr):
460651  root    
206632  bin     
  791   uucp    
   46   lp      
    4   daemon  
    1   adm     
/dev/rdsk/c0t0d0s7 (/export/home):
    9   root