Skip to main content
  1. Posts/

Clean up pacman cache automatically on Arch Linux

··296 words·2 mins·
Linux Arch Linux Pacman Linux Arch Pacman Pacman-Cache Paccache

I use Arch, btw. The pacman package manager is one of the major unique features of Arch Linux. pacman keeps the system up-to-date by synchronizing package lists with the master server. This model also allows the user to download/install packages with a simple command, complete with all required dependencies.

Pacman also stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove old versions automatically. This lets for packages to be downgraded/rolled back without having to download the previous version.

However, since the old packages are not cleaned up, this cache can grow indefinitely, and to a large extent. Pacman comes with some additional flags that can help prune this cache - most notably, you’ll see references commands like below

pacman -Rns $(pacman -Qdtq)

or

pacman -Scc

Having to do this repeatedly can be an annpoying thing and I wanted an automated way. Doing a bit of search, I came across paccache-hook - a simple utility that hooks into pacman’s post-transaction hooks to clean up the cache automatically.

paccache installs a hook to cleanup the pacman package cache using paccache whenever you run pacman. This ensures the pacman cache is cleaned up whenever you use pacman regularly.

Here’s an example output of the hook running automatically and cleaning up the cache:

:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Removing old packages from pacman cache...
Removing old installed packages...

==> finished: 136 packages removed (disk space saved: 2.57 GiB)
Removing old uninstalled packages...

==> finished: 23 packages removed (disk space saved: 4.24 MiB)

If you’re not happy with the default configuration, you can edit the conf file located in /etc/paccache-hook.conf to change the settings to your liking. This works with a pacman helper like yay as well, I haven’t tried with paru yet.

I hope this helps.

Sathyajith Bhat
Author
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist.

Related

Bash bashings..
··131 words·1 min
Tips & How-To's Bash Linux Popd Pushd
Since my new job involves lot more of Linux, shell scripting bash and automation, I’ve been trying to brush up my Linux skills. Ran into this “problem” today where there’s an init script which handles unicorn start/stop/reload and we were debugging some kinks around this. The init script had a chain of cd to the directory and the unicorn invoke script. Was trying to figure out why unicorn wasn’t starting up, till I read a bit more and dropped to using echo to understand what’s happening
Alienware X51 with Ubuntu makes no sense
··724 words·4 mins
Opinions Games Linux
This morning in my half-woken state, as I was checking Hacker News, I spotted this piece about Alienware launching the X51 with Ubuntu. I initially thought I was dreaming, and woke up immediately and read the piece, and I was left dumbfounded when I read it again to be sure. Kind of dumbfounded at Dell launching an Alienware X51 with Ubuntu https://alienware.com/ubuntu/ Not sure what’s Dell thinking - there aren’t any great native AAA games available, can’t imagine this would make studios to make Linux ports either
Reviving my dead Windows 8 install with no bootable USB/DVD and Linux Mint & Cr48
··587 words·3 mins
News Tips & How-To's Cr48 Linux Mint Windows
Couple of months ago, just about a month before #cpgweds - the engagement my Envy 14 laptop started showing signs of dying - weird noises coming from the vents, system freezing arbitrarily, system getting incredibly hot - and that’s really unusual because the Envy’s cooling system is probably one of the best that I’ve seen in a laptop. Soon enough, it became clear that a fan was not working - my idle temperatures hit 85 degrees C, and start any game or even xbmc, and the temperatures would hit 95-100 and shutdown sooner or later.