Thursday, April 28, 2011

Checking File Size and Disk Space in Linux

Linux comes with two commands that are useful for checking disk space usage.

df is used to check the space of mounted partitions
du is used to check the file sizes of files and directories

The most common use for df is to check partition free space. To make the output more human readable, use the -h option.

df -h

If you need to check on the size of a directory or its contents, use the du command. The most common options are -h (human readability), -a (display files and folders, not just folders) and -c (display a total size at the bottom).

cd /some/dir
du -ahc

For more advanced uses, run each command with the --help option for a list of additional options.

No comments:

Post a Comment