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 the highest file or directories, I already briefed on post Highest size files in the 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 the 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 13G /dump1/test/mydir 13G total
Here, the specified directory is 13GB. It’s a size of
/dump1/test/mydir directory not of
If you want to check the size of every object beneath the specified directory then you can skip
-s i.e. summery option from the command.
# du -ch /tmp 4.0K /tmp/hsperfdata_oracle11 4.0K /tmp/orbit-root ----- output clipped ----- 4.0K /tmp/keyring-VPiB3D 16K /tmp/lost+found 652K /tmp 652K total
In the above output, you can see each and every object’s size is given and finally at the end total is given which is the final size of the specified directory!
Let me know if you have any queries/questions/feedback in the comments. Also, drop us a message on our contact form.
Share Your Comments & Feedback: