How to figure out what is using all your Linux Diskspace
2 min read
I've been working on a server that someone else set up, and it is constantly running out of disk space, 102GB of disk space gone in a day. This leaves me to find and figure out where it is being used, clear whatever is using all this disk space and it's normally in the logs or our applications cache directory.
I did not set up this server, it's a Ubuntu 18.04 server but these commands should work for most flavors of Linux I believe.
The reason I am not trying to fix the problem is that I was told not to, when my development server is purchased and I set it up, it will not have these issues. I might make a guide to setting up a LAMP stack Ubuntu server but do we really need another one?
Here are the commands I use to locate where the disk space is being used the most at.
# View hard disk space df -h # View which directory is the largest, step by step to find large files sudo du -sh /* # Personally I like to just check log and tmp directory like just # keeping adding directorys seperated by a space sudo du -sh /var/log /tmp # find the largest file from the current directory, you can set max-depth to look into deeper subdirectories sudo du -h --max-depth=1 # Check your systemd log sudo du -sh /var/log/journal/ # Another way to check your systemd log sudo journalctl --disk-usage # If that is the problem then clean out the old data by deleting anything older then say 2 days sudo journalctl --vacuum-time=2d # And Maybe set max files saved sudo journalctl --vacuum-files=5
Did you find this article valuable?
Support Shawn Crigger by becoming a sponsor. Any amount is appreciated!