Thursday, July 21, 2011

How To Check Disk Usage in Linux System

df command will show the overall disk usage of the system.

#df -h

Output:

Filesystem            Size   Used     Avail    Use%    Mounted on
/dev/sda1              39G    35G      2.5G      94%      /
tmpfs                 283M          0    283M        0%      /lib/init/rw
udev                  279M    188K    278M        1%      /dev
tmpfs                 283M    156K    283M       1%      /dev/shm

Some of the options we can pass into the df command is as follow:

        -a, --all
              include dummy file systems
       -B, --block-size=SIZE
              use SIZE-byte blocks
       --total
              produce a grand total
       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)
       -H, --si
              likewise, but use powers of 1000 not 1024
       -i,  --inodes
              list inode information instead of block usage
       -k    like --block-size=1K
       -l,  --local
              limit listing to local file systems
       --no-sync
              do not invoke sync before getting usage info (default)
       -P, --portability
              use the POSIX output format
       --sync invoke sync before getting usage info
       -t, --type=TYPE
              limit listing to file systems of type TYPE
       -T, --print-type
              print file system type
       -x, --exclude-type=TYPE
              limit listing to file systems not of type TYPE
       -v     (ignored)


du command is used to estimate the specific usage of file or directory

# du -sch my_ntop_goes_here/

Output:

16M    my_ntop_goes_here/
16M    total

Some of the options we can pass into the du command is

       -a,  --all
               write counts for all files, not just directories
       -B,  --block-size=SIZE
               use SIZE-byte blocks
       -b,  --bytes
               equivalent to `--apparent-size --block-size=1'
       -c,  --total
              produce a grand total
       -D, --dereference-args
              dereference only symlinks that are listed on the command line
       -H    equivalent to --dereference-args (-D)
       -h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)
       --si  like -h, but use powers of 1000 not 1024
       -k    like --block-size=1K
       -l,  --count-links
              count sizes many times if hard linked
       -m   like --block-size=1M
       -L, --dereference
              dereference all symbolic links
       -P, --no-dereference
              don't follow any symbolic links (this is the default)
       -0, --null
              end each output line with 0 byte rather than newline
 

No comments:

Post a Comment