LinuxCommandLibrary

paccache

Clean Pacman's package cache

TLDR

Remove all but the 3 most recent package versions from the pacman cache

$ paccache [[-r|--remove]]
copy

Set the number of package versions to keep
$ paccache [[-rk|--remove --keep]] [num_versions]
copy

Perform a dry-run and show the number of candidate packages for deletion
$ paccache [[-d|--dryrun]]
copy

Move candidate packages to a directory instead of deleting them
$ paccache [[-m|--move]] [path/to/directory]
copy

SYNOPSIS

paccache [options]

PARAMETERS

-r, --remove
    Perform the removal of old package versions. This option must be specified for any files to be deleted.

-u, --uninstalled
    Remove all cached packages that are no longer installed on the system. Can be combined with -r.

-k , --keep
    Keep num versions of each installed package. The default is 3. A value of 0 means keep all versions (no removal). Only applies to installed packages when combined with -r.

-c

, --cachedir
    Specify an alternative package cache location to operate on, overriding the default.

-d , --dbpath
    Specify an alternative pacman database location, overriding the default. Useful for custom setups.

-s, --size
    Display the total size of the package cache before and after the operation. This provides a clear indication of disk space savings.

-v, --verbose
    Display the names of the files being removed during the operation, providing more detailed feedback.

-h, --help
    Show a help message and exit.

-V, --version
    Show version information and exit.

DESCRIPTION

The paccache command is a utility designed for managing the Arch Linux package cache, typically located at /var/cache/pacman/pkg/.

As packages are updated on a rolling-release distribution like Arch Linux, older versions of packages remain in the cache. While this allows for downgrades or reinstallation without re-downloading, it can consume a significant amount of disk space over time.

paccache helps to mitigate this by intelligently removing older package versions based on specified criteria, such as keeping a certain number of recent versions of installed packages or removing all cached packages that are no longer installed on the system. It's a crucial tool for maintaining disk space and system hygiene on Arch-based systems.

CAVEATS

Using paccache to aggressively prune the cache (e.g., -k 1 or removing uninstalled packages) can limit your ability to downgrade packages to older versions if a newer update causes issues. Once removed, a package must be re-downloaded if needed again.

COMMON USAGE EXAMPLES

Here are some common ways to use paccache:

To keep 3 latest versions of installed packages (default behavior for -r):
sudo paccache -r

To keep only the current version and one previous version of installed packages:
sudo paccache -r -k 1

To remove all uninstalled packages from the cache:
sudo paccache -r -u

To keep only the current version of installed packages and remove all uninstalled packages:
sudo paccache -r -uk 0

To display cache size before and after, and remove packages:
sudo paccache -r -s

HISTORY

paccache is not part of the core pacman package manager but is instead provided by the pacman-contrib package. It was developed as a complementary utility to address the common issue of ballooning package cache sizes in Arch Linux's rolling release model, where frequent updates can rapidly accumulate old package versions.

SEE ALSO

pacman(8), pacman.conf(5)

Copied to clipboard