Sunday, April 18, 2010

Two Useful Disk Utilization Commands: df and du

Here are two things that we keep doing:

1. Finding out the amount of free space available on the disk
2. Finding out the amount of disk space a particular folder is taking

If I am in front of the Linux machine with a Desktop environment, I can just right-click and see the properties. But that is a totally uncool thing to do when working on Linux, right?

So, here is the command-line way of doing it:

1. To finding out the amount of free space available on the disk, just type:

$ df -h

"df" is the tool used to report the file system disk space usage. Using the "-h" option prints the sizes in human readable format (like 10K, 11M, 40G, 10T, etc).

2. To find out the amount of disk space a particular folder is taking, go to that particular folder and type:

$ du -sch

or, you can give the folder name(s) as arguments to "du", for example:

$ du -sch /home/vinay/projects /home/vinay/local /home/vinay/music

"du" is the tool to estimate the file space usage. The "-s" option does a summary and displays only the total for each argument. The "-c" option produces a grand total. The "-h" option prints the sizes in human readable format.

If you want to know more about these commands, see these links
1. du: http://www.linfo.org/du.html
2. df: http://www.linfo.org/df.html

No comments:

Post a Comment