Pacman -Rns vs Rsc

I know that the later removes orphaned files, but is it safe to use?

I would be very cautious with -Rsc.

-s, --recursive
Remove each target specified including all of their dependencies,
provided that (A) they are not required by other packages; and (B)
they were not explicitly installed by the user. This operation is
recursive and analogous to a backwards --sync operation, and it
helps keep a clean system without orphans. If you want to omit
condition (B), pass this option twice.

-c, --cascade
Remove all target packages, as well as all packages that depend on
one or more target packages. This operation is recursive and must
be used with care, since it can remove many potentially needed
packages.

You might end up removing more than what you had in mind.

2 Likes

All versions of pacman -R are safe to use if you carefully read the list of packages to be removed before confirming the removal.

I wrote a brief description of the most common options here:

12 Likes

I’ll weigh in on this. What I was told by more than a few was just because you’re told a file is orphaned doesn’t mean that it/they are. My rule of thumb has been if it’s not causing issues to just leave it/them alone.

1 Like

Pacman -Rsc can come in handy when removing desktop environments.

As @dalto said, pacman always shows you what packages the transaction is going to remove. Look at the list carefully before pressing Y and you won’t remove more than you want.

If, by any chance you remove too much, you can always see exactly what you removed by looking at /var/log/pacman.log and you can always reinstall the missing packages. Also, pacman will not remove a package that is a dependency of another package that remains installed.

You can list the dependencies of a package using the pactree utility. pactree package-name will list all the dependencies of the package-name, and pactree -r package-name will list all the packages that depend on package-name.

Finally, it is a good idea to make a timeshift snapshot before removing a lot of stuff (like removing entire desktop environments), if you think there might be a chance you’ll need to undo that.

6 Likes

That is only true of certain options. Anything which includes -Rc will remove the dependent packages.

That is what makes it useful. It basically says remove this and anything else that depends on it. I use that almost exclusively. My theory is that pacman should never fail to remove something. Instead it should tell me what it takes to do what I am asking.

6 Likes

Yes, I meant, it won’t remove a dependency of a package that remains installed, thus breaking that package.

In other words, everything that remains installed will have its dependencies intact. You can’t accidentally end up with a system that has installed packages which do not have their dependencies installed, which would be bad.

3 Likes

Not handy if you do pacman -Rnsc gnome gnome-extra :slight_smile:
cause it removes networkmanager also :slight_smile:

1 Like

I suppose that you meant pactree -r package-name :wink:

Yes, I fixed it. Thanks!

I usually -Rc. And if I’m feeling really saucy -Rcns.

1 Like

Recursive Cascade :roll_eyes: Why ??

I use -Rsu

I want to make sure I salt the earth I scorch. That’s all.

3 Likes

This cannot be repeated or emphasized enough.

Whatever command you use don’t accept it if you don’t fully understand what is being removed.

As others have pointed out, pactree is a great tool for checking the dependency heirarchy of any package. All Arch users should become familiar with it.

3 Likes

I don’t know that, although I’ve used the Pacman -Rscn command before. I used to favor Gnome over KDE. Then I liked the simplicity and stability of Xfce, and its lower resource requirements, perhaps because it is similar to Debian in this respect, so I’ve been using this desktop environment for a long time. Because of all this, I haven’t used Gnome in a long time.