Ubuntu is one of the popular Linux distros for both Servers and Desktops. The main reason for this the number of tutorials and online community-based forums + knowledge-based articles. It really helps a lot to new users. Out of hundreds of command that we run on the Ubuntu command terminal, we often use Autoclean, Clean, and Autoremove. But what is the difference between them? Are they offer the same function or unique. Let’s see it:
Ubuntu apt-get commands to clean system space
1. apt-get autoclean
You may already have an idea about this Ubuntu clean command, what it does? Yes, in short, the cleaning. After using the Ubuntu system for quite some time, installing and uninstalling various software left residual files that didn’t need anymore, as we already have removed software uses those. Therefore, if your Ubuntu installed system hard drive doesn’t have much storage space then you can use this command to intermittently, remove the packages of the deleted software or no longer required archives available in a local repository on the hard disk.
Don’t worry the system will automatically identify the packages that are useless in most of the cases. This is not going to harm your existing installed software on the system.
sudo apt autoclean
2. apt-get clean:
Like the above command, this one also deletes all unnecessary packages from package cache. It clear the files downloaded for the installation of some program on Linux using APT. This means it removes .deb packages that download to the local repository from the apt repository and no longer required. Also, point to be noted that the command will not remove any installed package from your system, it only clears the cache.
Now, what is the difference between apt autoclean and apt clean commands, basically the “clean” one removes the downloaded .deb installer files residing in the /var/cache/apt/archives. For example, you have installed MySQL and after installing you removed it immediately or sometimes after. Now, if you again install it then the APT doesn’t need to fetch the installation packages from the online repository; instead, it will get them from a local cache storage. However, this also consumes hard disk space, if there is a new version available on the APT repo of the same program or you have uninstalled it. Then the cache of that would not be useful anymore. Hence, we can remove those .deb installer packages from Ubuntu/Debian Linux using the “apt clean” command. This is a good practice because in most cases these packages are useless.
Whereas the “autoclean”, as I told, it also removes packages that are useless, I mean leftovers of uninstalled programs or packages no longer needed or compatible on the system.
sudo apt clean
3. apt-get autoremove:
Remove packages that are installed to meet the dependencies of other packages, but are no longer needed because either the program has been uninstalled or got updated packages. Many times after upgrading Ubuntu or Debian, the system would automatically ask you to run this command, so that no longer needed installed packages can be removed to free up the system space.
After running this command the leftover of the removed dependencies can be clear using the autoremove command given above.
Furthermore, this command can be used in two ways, if you want to remove installed software packages but retain configuration files then
sudo apt-get remove
Where to delete the installed packages, that are no longer needed along with their configuration files, use:
sudo apt-get --purge remove
In this way, now and again, we can free up some space of our Ubuntu or Debian running PC using these three commands. However, if you are a user who doesn’t install or uninstall so many programs or packages on Linux, still Update or upgrading process also leaves unused packages on the system. Therefore, it is a good habit to clean your Ubuntu from time to time.
Know more about these command on the official page of the Ubuntu: