Skip to the content
pacman-master.com

pacman -Q: listing installed packages

To list the installed packages, run pacman -Q. The query operation reads the local database only, so it never touches the network, never needs root, and never changes anything on the machine.

pacman -Q
-Q
--query — ask the local database about packages that are already installed

Runs without root.

What it does. Print every installed package, one per line, as a name and a version separated by a space.

Watch out. No part of the query operation needs root, and none of it changes anything.

Query recipes

The modifiers filter the list or change what is printed about each entry:

CommandListsOutput shape
pacman -QEverything installed<name> <version>, one per line
pacman -QeOnly what you asked for explicitlysame, filtered to explicit installs
pacman -QdOnly what came in as a dependencysame, filtered to dependencies
pacman -QdtOrphans: dependencies nothing requires any moresame, and often empty on a tidy system
pacman -QmPackages not found in the sync databases, which on most machines means what was built from the AURsame
pacman -QnPackages that do come from the configured repositoriessame
pacman -QuInstalled packages that are out of date<name> <old> -> <new>
pacman -Qi <package>Everything the database records about one packagea block of Field : value lines, including Depends On, Required By and Install Date
pacman -Ql <package>Every file the package owns<package> <path>, one path per line
pacman -Qo <path>Which package owns a file that is already installed<path> is owned by <package> <version>
pacman -Qs <pattern>Installed packages matching a patternlocal/<name> <version> then an indented description
pacman -QkA check that the files each package owns are still on diskone line per package with the number of files missing
pacman -Qg <group>The installed members of a group<group> <name>
pacman -Qc <package>The change log, for packages that ship onethe text as the package author wrote it

Two of those rows have a page of their own: the dependency questions -Qd and -Qt answer are taken apart on the orphan page, and the file questions -Ql and -Qo answer sit next to their repository counterparts on the file ownership page.

Making the output usable by other commands

q strips everything but the names, which is what makes a query safe to hand to another command:

routinepacman -Qq

Names only, no versions.

routinepacman -Qqe

Names of the packages you installed explicitly — the closest thing to a list of what you chose to put on the machine.

routinepacman -Qdtq

Names of the orphans, ready to be passed to a removal command. See removing packages.

Counting them

pacman has no count option; the list is one package per line, so counting lines is the whole trick:

not pacmanpacman -Q | wc -l

A pipeline, not a single pacman command: wc is part of coreutils and the explainer refuses a line with a pipe in it rather than putting a level on half of it. The pacman half, pacman -Q, is in the cheat sheet with its own level.

Which package does this file belong to?

Two different questions, two different operations, and mixing them up is the usual reason one of them returns nothing:

QuestionCommandNeeds
Which installed package owns this file?pacman -Qo <path>Nothing; the file is on disk and the database knows it
Which package would provide this file, installed or not?pacman -F <name>The file databases, downloaded once with sudo pacman -Fy

Where the files actually are

PathHolds
/var/lib/pacman/The local database: what is installed and which files each package owns
/var/cache/pacman/pkg/The downloaded package files, kept after installation
/etc/pacman.confWhich repositories are enabled and the general options
/etc/pacman.d/mirrorlistThe servers used for the official repositories

Common questions

How to see installed packages with pacman?

Run pacman -Q. It prints every installed package as a name and a version, one per line, reading the local database without touching the network and without root.

How to get a list of installed packages that I chose myself?

Run pacman -Qe. The e modifier is --explicit, which restricts the list to packages installed by name rather than pulled in as dependencies. Add q for bare names.

Where are pacman packages installed?

To the paths recorded inside each package, which for most software is below /usr. pacman -Ql <package> lists every path a package owns. The downloaded package files are kept separately in /var/cache/pacman/pkg.

How do I find which package owns a file?

For a file already on disk, pacman -Qo <path>. For a file you do not have yet, pacman -F <name>, after downloading the file databases once with sudo pacman -Fy.

How to check this page

Two commands on your own machine: pacman -<operation> --help lists the modifiers that operation accepts, and man pacman opens the pacman(8) manual page these descriptions are written from. Where the descriptions come from, and what this site is not, is set out on the about page.

This page was last edited on .