How do I uninstall a bunch of useless programs all together

So after running pacman -Qdt (which I believe it shows all unnecessary dependencies)

image

I get a list of dependencies installed.

How do I automate the task by uninstalling all of these dependencies all together. Do I pipe it into it or something?

1 Like

Simply enter this:

sudo pacman -Rcs $(pacman -Qdqt)

3 Likes

So I am assuming that the $ is a variable, right? And you want to surround it in brackets () ?

You added a q does that mean quite mode like don’t prompt me for anything?

2 Likes

Okay, seems like a good time for a CLI tutorial using a very long term command (since late 60s) named the man pages.
open a terminal window, and enter
$ man pacman
Now for a break down of how to use it. NAME, SYNOPSIS, and DESCRIPTION are always a good start. Next we have OPERATIONS. The two we are interested in here are

       -Q, --query
           Query the package database. This operation allows you to view
           installed packages and their files, as well as meta-information
           about individual packages (dependencies, conflicts, install date,
           build date, size). This can be run against the local package
           database or can be used on individual package files. In the first
           case, if no package names are provided in the command line, all
           installed packages will be queried. Additionally, various filters
           can be applied on the package list. See Query Options below.
   -R, --remove
       Remove package(s) from the system. Groups can also be specified to
       be removed, in which case every package in that group will be
       removed. Files belonging to the specified package will be deleted,
       and the database will be updated. Most configuration files will be
       saved with a .pacsave extension unless the --nosave option is used.
       See Remove Options below.

Next is OPTIONS. scroll down to REMOVE OPTIONS (APPLY TO -R)
The ones we are interested in here are:

      -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.
      -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.

Scroll back to QUERY OPTIONS (APPLY TO -Q)
The ones we are interested are

      -d, --deps
           Restrict or filter output to packages installed as dependencies.
           This option can be combined with -t for listing real orphans -
           packages that were installed as dependencies but are no longer
           required by any installed package.
       -q, --quiet
           Show less information for certain query operations. This is useful
           when pacman’s output is processed in a script. Search will only
           show package names and not version, group, and description
           information; owns will only show package names instead of "file is
           owned by pkg" messages; group will only show package names and omit
           group names; list will only show files and omit package names;
           check will only show pairs of package names and missing files; a
           bare query will only show package names rather than names and
           versions.
      -t, --unrequired
           Restrict or filter output to print only packages neither required
           nor optionally required by any currently installed package. Specify
           this option twice to include packages which are optionally, but not
           directly, required by another package.

sudo pacman -Rcs $(pacman -Qdqt)
So I am assuming that the $ is a variable, right? And you want to surround it in brackets ()

I know what this does, not quite sure how it does it. So I will defer this to someone else to explain the syntax of this command,

Hope This Helps

Pudge

2 Likes

$(COMMAND) is shorthand for substitute output of the enclosed command
so:
sudo pacman -Rcs $(pacman -Qdqt)
says run pacman using the switches -Rcs and use the output of pacman -Qdqt as the targets.

1 Like

I assume that since pacman -Rcs included the -c (cascade) option, that essentially turned this into a loop.

Pudge

1 Like

pacman [options] [targets]
As I understand cascade it is only for one target, so if you have multiple targets, each target has its own cascade of dependent packages. The recursive part is within each target cascade. I know; clear as mud. If I’m wrong, someone please correct me. Makes me realize that I need to go back to “pacman school” before I get myself in trouble. :grinning:

2 Likes

Can i use this info for a new Discovery article?

2 Likes

I am going to assume that orphan packages means unnecessary packages?

I guess it will list everything that is not required out.

Thanks for your help :slight_smile:

1 Like

I think you should.

3 Likes

Can i use this info for a new Discovery article?

Absolutely. Let me know what you need from me, I’ll help in any way I can.

Pudge

1 Like

Could you send me a bare set up, so I can easily creare the article?

Keeping up with the news and creating articles on them, asks a lot of time for me.

1 Like

Go for it!

2 Likes

I use this site to clean my system

2 Likes