In this article, we cover a bit about clean option of apt command-line utility. apt is Ubuntu’s Advanced Packaging Tool. It is mainly used to install, remove and upgrade packages. Besides, we can also update Ubuntu repository through it.
When we install any package through a repository, it mainly downloads a .deb package file and then installs it for us. But, after the installation process is over. The .deb package file may or may not be deleted from our storage. This depends on the configuration we have chosen for our system.
If we have kept the settings in such a way that the package files are removed on its own once the installation process is over. Then, it would remove the package files accordingly. Also, one of option could be to remove only outdated package files. This was just to inform you that it can be done through a GUI package tool pretty easily. That we leave for some other article.
With clean option of apt utility, we can easily remove those package files.
Note: Following operations require superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.
apt clean in Ubuntu
The .deb package files are stored in directory –
This basically is our local repository. So, if the packages files are always in the directory then, Ubuntu would install the package (and, if its the latest one available) from here. But, if the packages are not found here then it downloads over the network or depends on how we have configured our system.
Now, sometimes we may not want packages in local repository for various reasons. So to clean the local repository, open a terminal and use the following –
sudo apt clean
It would clear everything from
/var/cache/apt/archives/partial. Only the
lock file would stay as it is.
But, next time we install any package which was earlier installed and we removed it later. We need to download the package again as we have cleared it from the local repository.
In conclusion, we have covered apt clean in Ubuntu here.