Deleting cache files

I see in the folder /var/cache/pacman/pkg there are a lot of files with extensions pkg.tar.zst. Is it safe to delete these as they taking up a fair chunk of space?

Those are the packages that were downloaded during an upgrade. pacman ─ or pamac if that’s what you’re using ─ downloads all the packages first, and then it starts upgrading the individual packages. That way, the risk of an upgrade going wrong is split between the phase of downloading the packages and the actual phase of upgrading your system.

  • If the network goes down while downloading the packages, you can always resume the download later.

  • If something goes wrong while upgrading your system, then you at least have all the packages on your system already, and then it’s easier to pick up from there.

It is generally advised to keep at least the packages from the last upgrade, but if you want to get rid of all of them, then just issue the following command… :arrow_down:

sudo paccache -rvk0

As an example from my own machine just now… :arrow_down:

[nx-74205:/dev/pts/1][/home/aragorn]
[13:00:00][aragorn] >  sudo paccache -rvk0
[sudo] password for root: 
removed '/var/cache/pacman/pkg/tree-1.8.0-2-x86_64.pkg.tar.zst'

==> finished: 1 packages removed (disk space saved: 33.39 KiB)

[nx-74205:/dev/pts/1][/home/aragorn]
[13:57:10][aragorn] >

Note: On my machine, sudo requires the password of the target user ─ in this case, the root account ─ rather than my own password. This is by choice. :wink:

4 Likes

Thnx for response. Now I know what they are, just found this useful website which says it all.

The Wiki would have told you that too. :stuck_out_tongue:

1 Like

It is done automatically for the user.

Check…

pamac-manager > Preferences > Cache:

Number of versions of each package to keep in the cache:

Updates /etc/pamac.conf.

Notice the systemd service, pamac-cleancache:

systemctl list-timers
1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.