How To Clear Apt Cache In Ubuntu – Free Disk Space In Ubuntu

Free Disk Space

How to Linux: Free up disc space on Ubuntu systems by deleting the Apt Cache. Learn how to use the apt-cache clean all command to clear out apt-cache archives or apt lists.

The /var/cache/apt/subdirectory takes up a lot of space after a frequent user. The folder takes up a lot of space and slows down the machine. It’s a good idea to empty the /var/cache/apt/ folder to help the system run quicker.

What exactly is the /var folder?

Apt Cache

‘/var’ holds variable data, i.e. files and folders that the system must be allowed to write to while running. Variable data, such as system logging files, mail, and printer spool folders, and transient and temporary files, are stored in the /var subdirectory. Some /var directories are not shared between computers. /var/log, /var/lock, and /var/run are a few examples.

What exactly is the /var/cache folder?

The /var/cache folder is a component of the /var folder structure. The /var/cache folder stores cached data from apps that are produced locally during I/O activities. These files can be erased without causing data loss since the data is only valid between application invocations and system reboots. When the procedure is completed, the data is no longer relevant.

APT Archive The cache should be cleaned.

Apt Cache

Apt archive cache may be cleaned using the sudo apt-get clean and sudo apt-get auto-clean commands in Ubuntu. apt-get is an APT package handling utility or command-line package handling tool. These commands remove all files from the local repository. The above auto clean command just removes out-of-date packages and files. Ubuntu users may accomplish the same thing using the Synaptic package manager. Navigate to Settings > Preferences > File tab in Synaptic. Select the option to remove packages that are no longer in use.

Run the following command on Ubuntu to clear the Apt archive cache folder:

sudo apt-get update
sudo apt-get clean
sudo apt-get autoclean

Please tell us more about the commands we used:

clean – clean removes all obtained package files from the local repository. Everything except the lock file is removed from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.

auto-clean — Autoclean, like clean, clears the local repository of retrieved package files. The distinction is that it only eliminates package files that can no longer be downloaded and are hence essentially ineffective. This allows a cache to be maintained for an extended period of time without becoming out of control. The configuration option APT: If Clean-Installed is turned off, installed packages will not be deleted.

Editor’s choice:

Leave a Reply