Do you want to free up disk space on your Ubuntu system? Try clearing the systemd journal log. It can free up a few GB of space.
Using the Disk Usage Analyzer tool, I found that Ubuntu 20.04 uses more than 4GB of system space for / var / log / journal.
Systemd has its own logging system called journals, and log files are stored in / var / log / journal. It is safe to delete these files unless you need logs for debugging. Then, the following steps will explain how to do this.
1. You can first open a terminal from the system app launcher and run a command to see the current disk usage of all journal files.
2. If you want to clear the log, run the command to rotate the journal file. All currently active journal files are marked as archived and will not be written in the future.
sudo journalctl --rotate
3. Select one of the following commands to clear the journal log.
- Delete journal logs older than X days.
sudo journalctl --vacuum-time=2days
- Deletes log files until the disk space used is less than the specified size.
sudo journalctl --vacuum-size=100M
- Delete old logs and limit the file number to X.
sudo journalctl --vacuum-files=5
4. You can also edit the configuration file to limit the journal log disk usage (for example, 100 MB).
Run the command in the terminal to edit the file through the Gedit text editor.
sudo -H gedit /etc/systemd/journald.conf
When the file opens, uncomment the line # SystemMaxUse = (remove the leading #) and change it to SystemMaxUse = 100M.
Save the file and reload the systemd daemon with the following command:
That’s it, enjoy!