Pacman commands: pacman -Sc and pacman -Scc

Yes, I am feeling rather newb-ish, but I’d rather ask first instead of blindly running a command and possibly borking my system. I just want to know if these are safe, won’t accidentally remove anything important, and how frequently should they be used.

I found these on the Pacman Rosetta web page and dug deeper in the terminal: man pacman.

man pacman:

SYNC OPTIONS (APPLY TO -S)
-c, --clean
Remove packages that are no longer installed from the cache as well as currently unused
sync databases to free up disk space. When pacman downloads packages, it saves them in a
cache directory. In addition, databases are saved for every sync DB you download from and
are not deleted even if they are removed from the configuration file pacman.conf(5). Use
one --clean switch to only remove packages that are no longer installed; use two to remove
all files from the cache. In both cases, you will have a yes or no option to remove
packages and/or unused downloaded databases.

I did a test run:

[keith@end ~]$ sudo pacman -Sc
[sudo] password for keith:
Packages to keep:
All locally installed packages

Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove all other packages from cache? [Y/n] n

Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] n
[keith@end ~]$ sudo pacman -Scc

Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove ALL files from cache? [y/N] n

Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] n
[keith@end ~]$

The third one down with the capital N is a good warning not to run this one. Correct?

Thanks in advance for any help, advice, and feedback.

Keith

Hi @keith!

A usually recommended way to handle pacman cache is to keep at least the previous version of each one.

Example, keep a previous version and update your system; Imagine you rebooted and noticed some of your loved packages stopped working.
One thing you could do is downgrade, meaning, installing the previous version from your cache without the need to redownload it to make your program resume working.

A not so agressive approach is to use paccache, for example paccache -rk1 this will keep the current version + 1 previous in your cache.

I don’t consider using pacman -Scc a risk, but i don’t think is necessary.

read more about paccache here https://wiki.archlinux.org/index.php/Pacman

2 Likes

i keep my cache to a minimum, got a paccache-hook from aur, only keep the two last versions, so always able to downgrade to a point dont need to go far back after all…

4 Likes

I use one previous version just in case something goes wrong so I can roll back. if you go in /var/cacche/pacman/pkg you will see a lot of packages. There’s no need for most of them. You can have one or 2 previous versions that you know work just in case and remove the rest.

Scroll down to claning the pacakge cache
https://wiki.archlinux.org/index.php/Pacman#Cleaning_the_package_cache

2 Likes

It looks like paccache is the safest way to go. And, my suspicions were right. There’s a red warning banner about using -Scc.

Thanks, everyone.

@fernandomaroto and @anon77235960 - You both sent me to the same page, so I don’t know who gets the credit for solving. :white_check_mark:

:thinking:

1 Like

I gladly let @fernandomaroto get the credit :smile:
He answered first so it only seems fair. The most important thing is that you got the help you needed though

3 Likes

Cheers! Done.

1 Like

No problem, as long as you have your answer :stuck_out_tongue:
:+1:

1 Like

Only to add, and not to prune by pruning directly with -rk0, -rk1, -rk2, … the command can be used -d in order to see the amount or volume of cache, then it would be:

sudo paccache -d
[sudo] password for judd: 
==> no candidate packages found for pruning   →(in my case) 

Done.

2 Likes

Isn’t the cache limited anyway?

limited by disk size or partition in case you have one for /var. Cache doesn’t make your system slow.

paccache -rk1
==> Privilege escalation required
==> finished: 24 packages removed (disk space saved: 297.79 MiB)

I can see how this can add up.

2 Likes

Hm, reading random threads can be useful:

 paccache -rk1
==> Privilege escalation required
==> finished: 3118 packages removed (disk space saved: 17.33 GiB)

Thanks to all for this one.

Why use the aur when creating your own hook takes a minute? Here’s my video posted in another thread:

4 Likes

nice Video :slight_smile:

My self i use the aur version because im lazy :slight_smile: also there are some additional configs in /etc/ currently using 2 hooks also for arch news, but is a good learn full video !

1 Like

I limited my cache to hold just one older version of a package, but it still fills up my root partition pretty fast. Running -Scc quite often.

use a pacman hook - does it for you - so no need for cleaning the cache anymore

edit;
wow- just saw it was almost a year old (well well)