Skip to content

Instantly share code, notes, and snippets.

@adierebel
Created September 7, 2024 12:58
Show Gist options
  • Save adierebel/c5d2d07797cc4d026a8d7e0ef0bb442c to your computer and use it in GitHub Desktop.
Save adierebel/c5d2d07797cc4d026a8d7e0ef0bb442c to your computer and use it in GitHub Desktop.
Cleanup Ubuntu Unused Files

Remove Journal Logs

sudo journalctl --vacuum-size=50M

Only keep 50mb of latest logs, and delete the rest.

Set max log file for journal, edit /etc/systemd/journald.conf, set SystemMaxUse to 50M then save.

Restart service:

sudo systemctl restart systemd-journald

Rotate logs

sudo logrotate -vf /etc/logrotate.conf

This should rotate the log files (so kern.log becomes kern.log.1); and you can then delete kern.log.1 etc to free up the disk space.

Search BIG files

Install NCDU

sudo apt-get install ncdu

Search for big files

sudo ncdu /

Delete only unused files, don't delete system file!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment