20

How can I get a list of packages that were explicitly installed by a user?

I'm aware of:

pacman -Qe
pacman -Qi

But those seem to include the default packages for my distribution (e.g. sudo). I want to list only the packages that were installed by a user using e.g. "pacman -Syu newpackage"

3 Answers 3

21

Arch Linux doesn't really have a set of default packages, though if you install from the guide you likely installed the base package group, and possibly base-devel. You can use comm to filter these (I'm assuming bash here):

comm -23 <(pacman -Qqett | sort) <(pacman -Qqg base-devel | sort | uniq)

You can use Qqe instead of Qqett if you want to include explicitly-installed packages that are also dependencies of some other package.

6
  • This worked well! So just to clarify, pacman also doesn't keep track of who installs something?
    – pandita
    Dec 10, 2017 at 9:50
  • 1
    @pandita On my system, attempts to install software as non-root yields error: you cannot perform this operation unless you are root. If you use sudo, you become root. So as far as pacman can tell, the only user who can install a package is root and there's no need to track that
    – Fox
    Dec 10, 2017 at 10:03
  • Try comm -23 <(pacman -Qqett | sort | uniq) <(pacman -Qqg base -g base-devel | sort | uniq) So they are both in the same sorted order
    – Ryan Ward
    Jun 4, 2018 at 13:27
  • 1
    This has a problem with circular dependencies. For example, jupyter is required by X which is required by Y .... which is required by jupyter. So although I explicitly installed it and it won't be installed as a dependency of any listed package, jupyter itself is not listed, which makes the output of this command unable to ensure reproducibility.
    – memeplex
    Feb 21, 2019 at 9:06
  • 4
    This answer is no longer working as now base is not a group, but a meta-package. Feb 12, 2021 at 7:11
1

simpler solution, that keeps historical order:

grep -i installed /var/log/pacman.log

however you will have upgrades in this list, and it will not contain explicitly installed only

1

alternate option that will include AUR

# packages installés explicitements - la base - les foreign
pacman -Qqe | grep -vx "$(pacman -Qqg base-devel)" | grep -vx "$(pacman -Qqm)" > main.lst

## Create local.lst of local (includes AUR) packages installed
# que les foreign
pacman -Qqm > aurandlocal.lst

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .