A Linux disk can fill up even when you haven’t installed any software recently. The APT cache is worth checking, but its presence does not prove that it is the cause. On Debian or Ubuntu, first measure the archives actually stored in the standard path, then check which filesystem contains them. You may conclude that the cache is too small to explain the problem and leave it alone.

Measure APT archives on the volume in question
This procedure is for Debian and Ubuntu systems using APT, assuming the archives are in /var/cache/apt/archives. Start with read-only checks, without elevated privileges. The commands answer three different questions: which version of APT is installed, which volume contains the path, and how much space the directory takes up.
apt --version
df -h /var/cache/apt/archives
du -sh /var/cache/apt/archives
ls -lh /var/cache/apt/archives
apt --version confirms that APT is available and displays its version. df, with the path as an argument, shows the used and available space on the filesystem containing that path. If the cache is on the root filesystem, you’ll see that volume’s figures. This is not a measurement of the cache alone.
du -sh estimates the size of the requested directory and displays a readable total. ls -lh shows the visible entries, their names, and their sizes: you can identify archive files, the partial subdirectory, and the lock file. This list is not a recursive total of all the contents of partial.
Also read any error messages from du. If the current user cannot access a subdirectory, the displayed total is incomplete. Only in that case, rerun the measurement with the necessary privileges:
sudo du -sh /var/cache/apt/archives
Don’t add sudo to read-only commands by reflex. Here, it is used to check contents that the first du could not access, particularly partial. Compare this corrected total before deciding. If you don’t see any permission errors, keep the command without sudo.
The standard path is not guaranteed. APT can be configured to put its caches elsewhere. If /var/cache/apt/archives does not exist, or you know the installation uses a different location, stop here: don’t run a cleanup on an assumed path. You can read the relevant settings without changing them:
apt-config dump | grep -E '^Dir( |::Cache)'
Relative values, such as archives/, are interpreted relative to their parent directory. So don’t copy them as-is as an absolute path. If the actual location is still uncertain, don’t clean anything as part of this procedure.
An empty or modest cache doesn’t call for a cleanup command. There is no universal threshold in megabytes or gigabytes above which APT is necessarily to blame. If du shows that the archives take up little space compared with the usage shown by df, stop here: the measurement does not justify deleting the cache.
Distinguish archives from installed packages
In /var/cache/apt/archives, APT keeps downloaded package files, usually .deb archives. These local files are not the software already installed and in use on the system. Removing them from the cache therefore does not uninstall the applications that are present.
Three similarly named commands perform different actions:
apt autocleanremoves archives that APT’s information no longer allows to be downloaded. The criterion is availability, not the file’s age or size.apt cleanremoves all downloaded archives from the local cache, including files in transit inpartial, according to the documented behavior.apt autoremoveconcerns packages installed automatically as dependencies that are no longer needed. It does not clean archives.
This procedure deals only with archives. Don’t use autoremove to address a cache-size issue: it acts on installed packages. clean and autoclean, on the other hand, are two possible alternatives depending on your needs, not two steps to copy and paste automatically.
Choose autoclean for a limited archive cleanup
Before running any APT command that modifies the cache, wait for any ongoing installation, update, or other APT operation to finish. Never delete the lock file to bypass a lock: it signals that an operation needs to retain control of the package manager.
Also check whether you plan to reinstall an older version kept in the cache while offline. autoclean specifically targets archives that can no longer be downloaded according to APT’s information; an archive that is still useful offline may therefore be removed. If you need to keep this backup, don’t run the command.
If selective cleanup suits your needs and you accept this limitation, run:
sudo apt autoclean
The expected result is the removal of archives that can no longer be downloaded according to the current state of APT’s information. The command may free up no space: there is no specific amount to expect before running it. “Not downloadable” does not mean “older than a certain number of days.”
The behavior also depends on the APT::Clean-Installed setting, which is enabled by default according to the documented APT configuration. It concerns archives associated with installed packages, not the uninstallation of those packages. Don’t change this setting as part of this diagnosis. Old indexes can also limit how effective the cleanup is. Updating the indexes is not an automatic prerequisite when you’re trying to free up space.
After autoclean, measure du again, following the same access rule as before. If the cache is now small enough, stop. Don’t move on to clean out of habit.
Clear archives with clean if you’re willing to download them again
clean is a different, broader decision: the command removes all downloaded archives in the local cache, including files in transit in partial, except for the lock file. It does not uninstall software that is already present. Before running it, consider whether you need the archives for an offline reinstallation or to retrieve a version that may no longer be available in the repositories.
A deleted archive may need to be downloaded again during an installation or reinstallation. This assumes a connection is available and that the required version can still be accessed. If the cache is your offline backup, keep it. This cleanup does not put files in a trash folder, and no automatic rollback is guaranteed.
If the cache is genuinely large, you don’t need this backup, and you’re willing to download the files later, wait for any APT operation to finish and then choose this command:
sudo apt clean
Don’t run it automatically after autoclean. Choose clean instead when your decision is to remove all archives. Never delete files manually or use rm in the cache: APT should perform the operation itself.
Check the cache and free space after the chosen action
After the chosen action, repeat the three checks. If the first du reported an access denial, apply the same exception with sudo to compare complete measurements:
du -sh /var/cache/apt/archives
ls -lh /var/cache/apt/archives
df -h /var/cache/apt/archives
du shows the current directory size, ls lets you check which entries are still visible, and df checks the available space again on the same filesystem as before. Compare measurements taken using the same method. The directory, partial, or lock may remain; a strictly zero size is not a requirement for success.
Don’t assume a specific amount of space will be freed before measuring it. df -h rounds the figures, so a small change may not be clearly visible. Other writes to the volume during the operation can also change the available space: any change cannot automatically be attributed to APT.
If the cache is small after verification but the disk is still almost full, move on from the APT procedure. Don’t repeat the cleanups or expand this procedure to other categories. Instead, use a general diagnosis to identify what is filling up the disk on Linux. The final decision is simple: if the archives don’t account for the measured usage, stop cleaning them and look for the cause using the appropriate diagnostic process.
Technical sources
- Debian manpage for apt-get(8): archive location and the behavior of
clean,autoclean, andautoremove. - Debian manpage for apt.conf(5): cache path configuration and the
APT::Clean-Installedsetting. - Debian manpage for apt-config(8): reading the APT configuration.
- GNU Coreutils manual, du and df: scope of directory and filesystem measurements.