Sunday, September 15, 2013

How to see disk space usage in linux

Estimating file space usage, we use "du" command.
du summarize disk usage of each file, recursively for directories.
It can be used with folders to get the total disk usage.

To see usage of /var/ we can run the following command

du /var/

The above command will show you the usage of each file in /var/ directory

If you add -c argument, it will include total size at the end.

du /var/ -c

If you want to see the summary only, use -s argument

du /var/ -s

If you want to see the size in human readable format, include -h argment

du /var/ -sh

du /var/ -h

du /var/ -ch

By default du dont include files which is not consuming any space.
If you want to include all files, use -a argument