What's the best way to clean up the /var/log/ directory on Ubuntu?
Asked by
CuriousCat42
My /var/log/ folder on Ubuntu 24.04.03 LTS is taking up 8 GB of space, which feels excessive. I've tried using 'sudo journalctl --vacuum-time=1d' but it didn't seem to make a difference. What are some effective methods to clean it up?
Answers
If you're looking for a quick clean, you can use the command 'sudo rm /var/log/*' to delete all files in that log directory. Just remember that new log files will be created as needed, so this is a short-term solution.
Reply to this answer
One option is to simply delete the files manually, but a more effective approach is to set up logrotate. It helps manage log files more efficiently without leaving your system cluttered.
Reply to this answer
Before cleaning, you might want to check which files are actually using up the space. That way you can target specific areas instead of just wiping everything out.
Reply to this answer
You can install a tool called 'ncdu' for a more detailed view of the log files. Run 'sudo apt install ncdu' followed by 'sudo ncdu /var/log'. This way, you can see what's eating up space. If it's mainly journal logs, you might want to vacuum them down to about 500 MB, but keep in mind this is just a temporary fix.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions