Skip to main content

Ubuntu CleanUp Command

  1. Get rid of packages that are no longer required. If you read the apt-get commands guide, you might have come across the apt-get command option autoremove.

This option removes libs and packages that were installed automatically to satisfy the dependencies of an installed package. If that package is removed, these automatically installed packages are useless in the system.

It also removes old Linux kernels that were installed from automatically in the system upgrade.

It’s a no-brainer command that you can run from time to time to make some free space on your Ubuntu system:

 sudo apt-get autoremove
  1. You can remove a program in Ubuntu from the software centre or using the command below with particular app name:
sudo apt-get remove package-name1 package-name2
  1. Clean up APT cache in Ubuntu Ubuntu uses APT (Advanced Package Tool) for installing, removing and managing software on the system, and in doing so it keeps a cache of previously downloaded and installed packages even after they’ve been uninstalled.

You can see the size of this cache with the du command below:

sudo du -sh /var/cache/apt 

Either remove only the outdated packages, like those superseded by a recent update, making them completely unnecessary.

sudo apt-get autoclean

Or delete apt cache in its entirety (frees more disk space):

sudo apt-get clean