How to find how much disk space a directory is consuming in Linux
In Category Command Line
The Linux command line utility “du” (disk usage) tells you how much space a file or a directory is taking on the disk. Just run the command against a file or a directory. If a directory is specified it determines disk space used by all files and sub directories recursively. By default it displays number in KB (kilo bytes) and the option “-h” makes it show the sizes in human-readable format.
[neo@techpulp ~]# du -h Videos/ 59M Videos/Animals 4.0K Videos/Funny 59M Videos/ [neo@techpulp ~]#
You might be wondering what is the use of “du” command against a single file as “ls -l” on any file shows the size of that file. The actual disk space used by a file could be more than actual size of the file shown in “ls -l“. Take a look at the following example where a file uses 4KB disk space while its original size is 12 bytes.
[neo@techpulp ~]# ls -lh dummy.txt -rw-rw-r-- 1 neo neo 12 2009-01-23 00:38 dummy.txt [neo@techpulp ~]# du -h dummy.txt 4.0K dummy.txt [neo@techpulp ~]#