If you are a Linux system administrator, you need a package manager to make your job easier. Pacman is a simple and handy tool that allows you to manage software packages in Arch Linux. With Pacman, you can install, update, remove, and list packages using the command-line interface.

This post will show you how to list installed packages with Pacman on Arch Linux.

Step 1 – Configure the Pacman Repository

By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirrorlist configuration file:

nano  /etc/pacman.d/mirrorlist

Remove all lines and add the following lines:

## Score: 0.7, United States
Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.8, United States
Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
## Score: 0.9, United Kingdom
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
## Score: 1.5, United Kingdom
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
## Score: 6.6, United States
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
## Score: 6.7, United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
## Score: 6.8, United States
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
## Score: 7.1, India
Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
## Score: 10.1, United States
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch

Save and close the file, then update all the package indexes with the following command:

pacman -Syu

Step 2 – List Installed Packages Using Pacman

You can use the Pacman command with the -Q option to list all installed packages on your system.

pacman -Q

You should see the list of all installed packages in the following output:

acl 2.3.1-2
acpid 2.0.34-1
archlinux-keyring 20220927-1
argon2 20190702-4
attr 2.5.1-2
audit 3.0.8-1
autoconf 2.71-1
automake 1.16.5-1
bash 5.1.016-1
binutils 2.39-3
bison 3.8.2-4
brotli 1.0.9-8
bzip2 1.0.8-4
ca-certificates 20220905-1
ca-certificates-mozilla 3.84-1
ca-certificates-utils 20220905-1
chrpath 0.16-3
coreutils 9.1-1

In the above command, you should see two columns. The first column is the name of the installed packages and the second column is the version of the installed packages.

If you want to export the list to a file, run the following command:

pacman -Q > packages.txt

This will create a new file named packages.txt in your current working directory.

Step 3 – List Only the Later Installed Packages

You can also list all packages that are installed later using the Pacman command. To list later installed packages, use the -Qe option:

pacman -Qe

You should see a list of later installed packages in the following output:

acpid 2.0.34-1
autoconf 2.71-1
automake 1.16.5-1
bash 5.1.016-1
binutils 2.39-3
bison 3.8.2-4
bzip2 1.0.8-4
coreutils 9.1-1
cryptsetup 2.5.0-1
debugedit 5.0-4
device-mapper 2.03.16-2
dhcpcd 9.4.1-1
diffutils 3.8-1
e2fsprogs 1.46.5-4
expac 10-5
fakeroot 1.29-1

To list more system packages, run the following command:

pacman -Qet

You should see the following output:

acpid 2.0.34-1
autoconf 2.71-1
automake 1.16.5-1
bison 3.8.2-4
debugedit 5.0-4
expac 10-5
fakeroot 1.29-1
flex 2.6.4-3
gcc 12.2.0-1
grub 2:2.06.r334.g340377470-1
haveged 1.9.18-1
inetutils 2.3-1
iputils 20211215-1
jfsutils 1.1.15-8
licenses 20220125-1
linux 6.0.2.arch1-1
make 4.3-3
man-db 2.11.0-1
man-pages 6.01-1

Step 4 – List Only the Installed Package Names

By default, the Pacman command generates all installed package lists in two columns. If you want to show only the first column, run the following command:

pacman -Q | awk '{print $1}'

You will get the following output:

acl
acpid
archlinux-keyring
argon2
attr
audit
autoconf
automake
bash
binutils
bison
brotli
bzip2
ca-certificates
ca-certificates-mozilla
ca-certificates-utils
chrpath
coreutils
cracklib

To export the above list to a file, run the following command:

pacman -Q | awk '{print $1}' > package_list.txt

Conclusion

In this post, we explained how to list packages in Arch Linux using the Pacman command. You can now use the Pacman command on dedicated hosts from Atlantic.Net!