Posts

Posts uit februari, 2026 tonen

how to clean systemd journal logs & free disk space on Linux

Systemd journal logs are useful for troubleshooting. But over time, they can quietly consume gigabytes of disk space especially on servers. I show you how to: • Check journal log disk usage  • Delete old logs safely  • Limit logs by size  • Restrict the number of log files  • Make log limits permanent  • Prevent your server from running out of space  This works on Ubuntu, Debian, Fedora, Arch, and most modern Linux distributions using systemd.   Check Current Journal Disk Usage  journalctl --disk-usage   This shows how much space systemd journal logs are currently using.   Delete Logs Older Than X Days To remove logs older than 14 days:  sudo journalctl --vacuum-time=14d  You can change 14d to: 7d (7 days) 30d (30 days) 2m (2 months) This removes archived logs older than the specified time.   Limit Journal Logs by Total Size Limit total size to 500MB (example):  sudo journalctl --vacuum-size=500M  ...

The APT package manager includes an auto-remove feature that can clean up unnecessary packages, including old kernels:

 sudo apt autoremove --purge   This command removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed, including old kernels. However, autoremove only removes kernels that were installed automatically . In case we install a kernel manually, this method might not remove it. Alternatively, we can also install byobu . It’s a command-line tool which can simplify the cleanup process:   sudo apt-get install byobu  After installation, let’s remove the old kernels:   sudo purge-old-kernels  The  purge-old-kernels command keeps the current and previous kernel, removing all other old kernels.