How do I get a list of all packages installed on a system

I would really like a list of all packages I have explicitly installed, but that is probably not possible. The reason is that I have just installed Manjaro to another drive (nvme) and would like the new installation to have all the same packages as my old system (which I can still boot). I’ve looked at pacman and found the command “pacman -Ql”, but it lists many lines for each package (looks like one for each file in the package). I know a suggestion might be to just use some disk mirroring software and copy the older sdd to the new nvme, but the old system is not uefi, new system is. My (new) machine only has UEFI, not legacy bios. This seems like something that someone would have wanted to do already, so I would think that it is possible. Can anyone help?

Open a terminal run:

pacman -Qqe > pkglist.txt

In the directory the terminal is in, you will find a file called pkglist.txt with every package that is installed.

1 Like

Thanks! If I try to install all these packages, many if not most of which will already be installed, will that bork my system? Or will already installed packages just be ignored?

It will still be reinstalled with ignorable warning, overwriting each file with itself.

you should be fine, this is the process used if you need to delete your pacman DB for some reason. It “shouldn’t” break any thing.

Don’t forget to always read the wiki

https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#List_of_installed_packages
https://wiki.archlinux.org/index.php/Pacman

Yeah, I think I will 1) get the list of packages on my old system and move it to the new system. 2) get the list of packages on the new system. 3) use the sort cmd to merge the files, sorted. 4) use the uniq cmd to remove all lines that have duplicates. 5) I will then have the list of packages that are on the old system, but not the new system. Any comments on this approach? (Well, it occurs to me that it will also include any packages on the new system that aren’t on the old system as well).

Thanks tuxmanjarino. I posted my previous post before reading your reply. And I did look at the manjaro wiki, just not the arch wiki.

Hey zeddie,

You can use:

comm -12 <(grep -Poe '\[ALPM\] installed \K\S*' /var/log/pacman.log | sort | uniq) <(pacman -Qeqn | sort)

to get a list of all packages that you have installed on top of the default ones. If you installed AUR packages, you can use:

comm -12 <(grep -Poe '\[ALPM\] installed \K\S*' /var/log/pacman.log | sort | uniq) <(pacman -Qeqm | sort)

6 Likes