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:
| Command | Lists | Output shape |
|---|---|---|
pacman -Q | Everything installed | <name> <version>, one per line |
pacman -Qe | Only what you asked for explicitly | same, filtered to explicit installs |
pacman -Qd | Only what came in as a dependency | same, filtered to dependencies |
pacman -Qdt | Orphans: dependencies nothing requires any more | same, and often empty on a tidy system |
pacman -Qm | Packages not found in the sync databases, which on most machines means what was built from the AUR | same |
pacman -Qn | Packages that do come from the configured repositories | same |
pacman -Qu | Installed packages that are out of date | <name> <old> -> <new> |
pacman -Qi <package> | Everything the database records about one package | a 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 pattern | local/<name> <version> then an indented description |
pacman -Qk | A check that the files each package owns are still on disk | one 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 one | the 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:
pacman -QqNames only, no versions.
pacman -QqeNames of the packages you installed explicitly — the closest thing to a list of what you chose to put on the machine.
pacman -QdtqNames 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:
pacman -Q | wc -lA 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:
| Question | Command | Needs |
|---|---|---|
| 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
| Path | Holds |
|---|---|
/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.conf | Which repositories are enabled and the general options |
/etc/pacman.d/mirrorlist | The 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.