How to Linux – Free up disk space by clearing Apt Cache in Ubuntu Systems. Learn how to clean apt cache archives or clean apt lists using apt-cache clean all command.
After a regular user, a lot of space is occupied by /var/cache/apt/ folder. The folder consumes a lot of space and slows the system performance. It is wise to clear the /var/cache/apt/ folder to make the system faster.
What is /var folder?
‘/var’ contains variable data, i.e. files and directories the system must be able to write to during system operation. /var folder contains variable data like system logging files, mail and printer spool directories, and transient and temporary files. Some folders of /var are not shareable between different systems. For example, /var/log, /var/lock, and /var/run.
What is /var/cache folder?
/var/cache folder is a part of /var folder system. /var/cache folder is intended for cached data from applications that are locally generated during I/O operations. These files can be deleted without any data loss as these data remains only valid between invocations of the application and rebooting of the system. When the process gets over the data is no more important.
Clean APT Archive Cache
Ubuntu users can clean Apt archive cache using sudo apt-get clean and sudo apt-get autoclean commands. The apt-get is a APT package handling utility or the command-line tool for handling packages. These commands clears out the local repository. The above autoclean command only removes packages and files that are no longer in use. Ubuntu users can also do the same task from Synaptic package manager. Open Synaptic, go to Settings > Preferences > File tab. Select to delete packages that are no longer in use.
To clean Apt archive cache folder on Ubuntu, run:
sudo apt-get update
sudo apt-get clean
sudo apt-get autoclean
Let us know more about the commands we have used:
clean – clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.
autoclean – Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.