Remove multiple packages and their own dependencies (not required by other packages)

The pacman documentation shows a very easy way to install multiple packages:
pacman -S package1 package2 package3 …
But only shows the removal of 1 at a time:
pacman -Rs package1
So is there a way to remove multiple packages and their dependencies (not required by other packages)? Logically it would simply be:
pacman -Rs package1 package2 package3 …
But this example is not shown.

Thanks in anticipation,

Broadsworde

1 Like

pacman -Rnsu pack1 pack2 ...

Edit:

I have found a lot of useful tips here
https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks

1 Like

your logical thinking is correct.

this works well.
the downside is: if you have misspelled one package name (or one package is a dependency) you have to fix a long command.
also, you have to know the exact names of the packages you want to remove.

Thank you fhdk, I checked that link... as you say very useful, but I didn't see the multiple removal example their either. Did I miss it?

Thank you excalibur1234, the dependencies issue certainly complicates things, but as for knowing and spelling the packages correctly the same could be said of the installing multiple packages process (which the documentation does provide an example of). I think for now, as I'm getting used to the new distro I should perhaps go 1 by one.

That might be possible not every possible combination is covered.

As you already know

-Rs removes a package or should we say the named packages from the supplied space-separated list
-Rsn removes configuration files
-Rsnu removes unneeded files
Note: If the u-switch is present and the command will break other dependencies pacman will print a message for every package which has been excluded from the command.

So to answer your question - to remove all remnants including configurationfiles and own dependencies(not required by other packages) you would issue

$ sudo pacman -Rnsu pack1 pack2 ...

But try pacman --help -R to get comprehensive list of options for removal or man pacman for the full manual

Note if you are trying to convert a systemd system to openrc you need to remove systemd neither -Rnsu or -Rd will work the only one that works is -Rdd.

1 Like

personally, i use "sudo pacman -Rsn ..." to remove one or multiple packages and i never had a problem with it. "sudo pacman -Rsun ..." would be fine as well.

but i strongly recommend NOT to use "sudo pacman -Rsunc ..." unless you know exactly what you are doing!!!

2 Likes

I either work for a copy/paste list or, without one, open another terminal and use pacman -Ss to get the correct pkg name, then copy/paste to the working terminal.

My low-tech ways stem from old age. :wink:

Regards

1 Like

as long as the package name is the same as the application starter name, one can also use sudo pacman -S bash-completion to get the names with Tab - but unfortunately, not all packages have the same names as their programs

oh yes. i agree.

this is especially annoying when i install a package and want to start the program from CLI.
this is the reason i included a handy option into pacli-simple, which quickly shows me the name of the installed program. this option is explained here, if you are interested to read about it:
https://github.com/excalibur1234/pacli-simple/blob/master/pacli#L559

1 Like

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

Forum kindly sponsored by