Skip to content

Instantly share code, notes, and snippets.

@andrewpayne68
Last active November 18, 2025 16:16
Show Gist options
  • Select an option

  • Save andrewpayne68/eac256e1ef9ed5fb9258898b742caa67 to your computer and use it in GitHub Desktop.

Select an option

Save andrewpayne68/eac256e1ef9ed5fb9258898b742caa67 to your computer and use it in GitHub Desktop.
To clean up an Ubuntu 22.04 / 24.04 server

To clean up an Ubuntu 22.04 / 24.04 Server

Package and cache cleanup

Clear the apt package cache: This removes downloaded package files that are no longer needed.

sudo apt clean

Remove unused packages: This command removes packages that were automatically installed to satisfy dependencies for other packages but are no longer needed.

sudo apt autoremove

Clean up outdated packages: This is similar to autoremove but also removes older versions of packages that are no longer installable.

sudo apt autoclean

Journal log cleanup

Check current journal size: Before deleting, check how much space the journal logs are using.

sudo journalctl --disk-usage

Vacuum journal logs: These commands reduce the size of the journal logs. To delete logs older than a specific time:

sudo journalctl --vacuum-time=2days

To delete logs until the total size is below a certain amount:

sudo journalctl --vacuum-size=100M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment