Learn how to get directory total size in Linux without calculating each and every file’s size within. Handy command to troubleshoot mount point utilization.
Many times we need to check specific directory size to hunt down culprit of mount point utilization. There are scenarios where mount points keeps getting full and we need to investigate which file or directory is hogging most of space.
Collectively to check highest file or directories, I already briefed in post Highest size files in mount point. Lets 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 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 size of every objects beneth 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 an message on our contact form.