When troubleshooting any disk space problems on a server or just trying to find the largest directories, the
du command is essential!
You can use the
du command which estimates the directory space usage.
For example, let’s say that we want to check the size of the directories located in the
/home directory. To do that let’s first
cd into the
- cd /home/
And then run the
- du -h --max-depth=1
[secondary_label Output] 16K ./demo 5.0G ./bobby 28K ./sammy 1.8G ./dev 7.1G .
I like running the
du command with the
--max-depth=1 argument which only shows the size of the folders located inside the current directory and not the subfolders.
As you can see from the output the size is not sorted by size, here is how to do that!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Click below to sign up and get $100 of credit to try our products over 60 days!