Learn how to get directory total size in Linux without calculating each and every file’s size within. A very handy command to troubleshoot mount point utilization.
Many times we need to check specific directory size to hunt down the culprit of mount point utilization. There are scenarios where mount points keep getting full and we need to investigate which file or directory is hogging most of the space.
Collectively to check highest file or directories, I already briefed on post Highest size files in mount point. Let’s see how we can get directory’s collective size in one go.
We will be using disk usage command ‘du’ and below of its options :
- -s : Display only summary of each element
- -h : Human readable format for size i.e. KB, MB, GB
- -c : Produce grand total i.e. display the total size
# du -sch /dump1/test/mydir
Here, specified directory is of 13GB. Its a size of /dump1/test/mydir directory not of /dmp1.
If you want to check the size of every object beneath the specified directory then you can skip -s i.e. summery option from command.
# du -ch /tmp
----- output clipped -----
In above output, you can see each and every object’s size is given and finally at the end total is given which is final size of the specified directory!
Let me know if you have any queries/questions/feedback in comments. Also, drop us a message on our contact form.