Free up disk space on Arch Linux by clearing your pacman cache

Generally speaking, I tend to run Linux with a single partition. But, with my
work laptop, I [for some unknown reason] had opted to run with a dual partition
setup, for root / and home /home.

Not the most earth shattering setup, but I did end up starving my root /
partition a bit, so from time to time GNOME barks about my that partition being
low on space.

Fortunately, it hasn’t been enough of an inconvenience to force me to take the
time to resize my partitions, mainly because it doesn’t take much to get things
back in order. The major disk space hog for me, with this configuration, has
been pacman’s cache.

Clearing the cache is a quick and painless process. With one command, you’re
able to remove all of the packages that have been downloaded by pacman.

Keep in mind, pacman doesn’t remove packages from the cache, even when you
uninstall something! While not that big of a deal if you have a decent sized
hard disk, it’s still worth pointing out you may want to run this command
periodically just to clean things up.

To clear the cache of packages that pacman has downloaded, simply run:

pacman -Sc # Requires super user privileges

Then confirm that you’d like to remove all of the packages from the cache
directory /var/cache/packman/pkg/, wait a moment (or a few moments depending
on how large your cache is) while it runs. Then you’ll want to confirm whether
or not you’d like to remove any unused repositories from /var/lib/pacman/, and
you’ll be all set!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

If you found this article helpful, please consider buying me a coffee.