pacman — quick reference
Sync, install, and upgrade (-S)
| When to use | Command |
|---|---|
| Full system upgrade (sync + refresh + upgrade) | sudo pacman -Syu |
| Install a package from repos | sudo pacman -S package_name |
| Install only if not already present | sudo pacman -S --needed package_name |
| Install multiple packages | sudo pacman -S pkg1 pkg2 |
| Refresh package database only | sudo pacman -Sy |
| Force refresh all mirrors | sudo pacman -Syy |
| Download package without installing | sudo pacman -Sw package_name |
Install a local .pkg.tar.zst file |
sudo pacman -U package.pkg.tar.zst |
Always prefer -Syu before installing on Arch — partial upgrades break dependencies.
Remove (-R)
| When to use | Command |
|---|---|
| Remove a package, keep deps | sudo pacman -R package_name |
| Remove package and unused dependencies | sudo pacman -Rs package_name |
| Remove package, deps, and config files | sudo pacman -Rns package_name |
| Force remove ignoring deps (dangerous) | sudo pacman -Rdd package_name |
Query installed packages (-Q)
| When to use | Command |
|---|---|
| List all installed packages | pacman -Q |
| List explicitly installed (not deps) | pacman -Qe |
| Search installed packages by keyword | pacman -Qs keyword |
| Show installed package details | pacman -Qi package_name |
| List files installed by a package | pacman -Ql package_name |
| Find which package owns a file | pacman -Qo /path/to/file |
| List orphan packages | pacman -Qtd |
| Check package file integrity | pacman -Qk package_name |
Search repositories (-S query)
| When to use | Command |
|---|---|
| Search repos by keyword | pacman -Ss keyword |
| Show repo package details | pacman -Si package_name |
File database (-F) and database ops (-D)
| When to use | Command |
|---|---|
| Refresh file database | sudo pacman -Fy |
| Find which package contains a filename | pacman -F filename |
| Mark package as dependency | sudo pacman -D --asdeps package_name |
| Mark package as explicitly installed | sudo pacman -D --asexplicit package_name |
Cache maintenance
| When to use | Command |
|---|---|
| Remove uninstalled package files from cache | sudo pacman -Sc |
| Remove all cached package files | sudo pacman -Scc |
Help and version
| When to use | Command |
|---|---|
| Show pacman version | pacman --version |
| Show option help | pacman -S --help |
pacman — command syntax
Synopsis from pacman(8) on Arch Linux:
pacman <operation> [options] [targets]Main operations: -S (sync/install), -R (remove), -Q (query local DB), -U (upgrade local package), -F (file search), -D (database tweak). Configuration: /etc/pacman.conf. Sync databases: /var/lib/pacman/sync/.
pacman — command examples
Essential Full system upgrade (-Syu)
On Arch, always sync the database and upgrade the system before installing new software — partial upgrades cause dependency breakage.
Run the command:
sudo pacman -SyuSample output:
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
Packages (3) curl-8.8.0-1 openssl-3.3.0-1 pacman-7.0.0-1
Total Download Size: 12.50 MiB
Total Installed Size: 45.00 MiB
:: Proceed with installation? [Y/n] y
...
(3/3) checking keys in keyring [----------------------] 100%
(3/3) checking package integrity [----------------------] 100%
(3/3) loading package files [----------------------] 100%
(3/3) checking for file conflicts [----------------------] 100%
(3/3) checking available disk space [----------------------] 100%
:: Processing package changes...
(1/3) upgrading curl [----------------------] 100%
(2/3) upgrading openssl [----------------------] 100%
(3/3) upgrading pacman [----------------------] 100%
:: Running post-transaction hooks...
(1/1) Restarting accounts daemon...Essential Install a package from official repos
Install one package after the system is up to date — combine upgrade and install in one transaction when possible.
Run the command:
sudo pacman -Syu htopOr install without upgrading other packages (only when you already ran -Syu recently):
sudo pacman -S htopSample output:
resolving dependencies...
looking for conflicting packages...
Packages (1) htop-3.3.0-1
Total Installed Size: 0.45 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [----------------------] 100%
(1/1) checking package integrity [----------------------] 100%
(1/1) loading package files [----------------------] 100%
(1/1) checking for file conflicts [----------------------] 100%
(1/1) checking available disk space [----------------------] 100%
:: Processing package changes...
(1/1) installing htop [----------------------] 100%Verify:
pacman -Qi htop | grep -E '^Name|^Version|^Installed Size'Sample output:
Name : htop
Version : 3.3.0-1
Installed Size : 450.00 KiBEssential Remove a package and unneeded dependencies
Remove software and cascade-delete dependencies nothing else needs.
Run the command:
sudo pacman -Rns htopSample output:
checking dependencies...
Packages (1) htop-3.3.0-1
Total Removed Size: 0.45 MiB
:: Do you want to remove these packages? [Y/n] y
(1/1) removing htop [----------------------] 100%Common Search repositories before installing
Find the exact package name in official repos — search matches name and description.
Run the commands:
pacman -Ss nginx
pacman -Si nginxSample output:
extra/nginx 1.26.0-1
Lightweight HTTP server and IMAP/POP3 proxy server
...
Name : nginx
Repository : extra
Version : 1.26.0-1
Description : Lightweight HTTP server and IMAP/POP3 proxy server
Architecture : x86_64
URL : https://nginx.org/
Licenses : BSD-2-Clause
Groups : None
Provides : None
Depends On : openssl pcre zlib geoip libxml2
Optional For : None
Conflicts With : None
Replaces : None
Download Size : 520.00 KiB
Installed Size : 1.50 MiBCommon Find which package owns a file
Trace an unexpected binary or config file back to its package — useful after manual edits or security audits.
Run the commands:
pacman -Qo /usr/bin/bash
pacman -Ql pacman | head -5Sample output:
/usr/bin/bash is owned by bash 5.2.15-1
pacman /usr/
pacman /usr/bin/
pacman /usr/bin/pacman
pacman /usr/share/
pacman /usr/share/man/Common Remove orphan packages
After uninstalling meta-packages, leftover dependencies clutter the system — remove orphans safely.
Run the commands:
pacman -Qtd
pacman -Qtdq | sudo pacman -Rns -Sample output:
orphan1 1.0-1
orphan2 2.0-1
...
checking dependencies...
:: Do you want to remove these packages? [Y/n] yAdvanced Install or downgrade from a local package file
Install a vendor RPM-style drop-in or roll back using a file still in the cache.
Run the command:
sudo pacman -U /var/cache/pacman/pkg/nginx-1.24.0-1-x86_64.pkg.tar.zstSample output:
loading packages...
resolving dependencies...
looking for conflicting packages...
Packages (1) nginx-1.24.0-1
Total Installed Size: 1.40 MiB
Net Upgrade Size: -0.10 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [----------------------] 100%
...
downgrading nginx [----------------------] 100%Downgrades may require --overwrite '*' when file conflicts appear — use only when you understand the conflict.
Advanced Search the file database for a missing command
When you know a filename but not the package, refresh -F and search (requires pacman -Fy periodically).
Run the commands:
sudo pacman -Fy
pacman -F useraddSample output:
:: Updating 5 repos...
downloading core.db...
core/etc/default/useradd
core/shadow (4.14.0-1)
usr/bin/useradd
core/shadow (4.14.0-1)Advanced Clean package cache
Free disk space under /var/cache/pacman/pkg/ — -Sc keeps installed versions; -Scc removes everything.
Run the commands:
sudo pacman -Sc
sudo pacman -SccSample output:
Cache directory: /var/cache/pacman/pkg/
Packages to keep:
All locally installed packages
Cache cleanup: 15 packages removed, 120.00 MiB freed
...
Cache directory: /var/cache/pacman/pkg/
...
Cache cleanup: All packages removed, 850.00 MiB freedAfter -Scc, offline downgrades need re-downloading from mirrors.
pacman — when to use / when not
| Use pacman when | Use something else when |
|---|---|
|
|
pacman vs apt vs dnf
| pacman | apt | dnf | |
|---|---|---|---|
| Distro | Arch | Debian/Ubuntu | RHEL/Fedora |
| Full upgrade | pacman -Syu |
apt update && apt upgrade |
dnf upgrade |
| Remove + deps | pacman -Rns |
apt autoremove |
dnf autoremove |
| Local package | pacman -U file.pkg.tar.zst |
dpkg -i / apt install ./deb |
dnf install ./rpm |
| Partial upgrade risk | High — avoid -Sy then install |
Moderate | Moderate |
Related commands
Package and build tooling on Arch.
| Command | One line |
|---|---|
| pacman | Official Arch package manager (this page) |
Browse the full index in our Linux commands reference.
pacman — interview corner
What is pacman in Arch Linux?
pacman is Arch's native package manager. It downloads packages from mirrors listed in /etc/pacman.conf, verifies signatures, installs files tracked in the local package database (/var/lib/pacman/), and handles dependencies for official repos.
Core operations map to letters: -S sync/install, -R remove, -Q query local DB, -U install local package file.
A strong answer is:
"pacman is Arch's package manager — -S install/sync, -R remove, -Q query. It works with official repos in pacman.conf and keeps the local package DB under /var/lib/pacman/."
What does pacman -Syu do?
It runs a full system upgrade in one transaction:
| Flag | Meaning |
|---|---|
| -S | Sync (install/upgrade from repos) |
| -y | Refresh package databases |
| -u | Upgrade all installed packages |
Arch expects regular -Syu — installing with -Sy alone then -S pkg without -u causes partial upgrades and broken dependencies.
A strong answer is:
"-Syu refreshes databases and upgrades all packages together. On Arch I avoid partial upgrades — I run -Syu before installing new software."
What is the difference between pacman -R and -Rns?
| Option | Removes | Also removes |
|---|---|---|
-R |
The package | Nothing else automatically |
-Rs |
Package | Dependencies not required by other packages |
-Rns |
Package + deps | Config files marked as backup |
Use -Rns for normal uninstalls; -Rdd only when you understand dependency breakage.
A strong answer is:
"-R removes the package only. -Rns also removes unneeded dependencies and config files — that's my default uninstall. -Rdd ignores dependencies and is a last resort."
When do you use pacman -Qo vs pacman -F?
| Command | Needs | Answers |
|---|---|---|
pacman -Qo /path |
File on disk | Which installed package owns it |
pacman -F name |
Updated file DB (-Fy) |
Which repo package contains that path |
Use -Qo for audits of the live system; use -F when the file is not installed yet.
A strong answer is:
"-Qo queries the installed system — who owns this file. -F searches repo file lists after pacman -Fy — useful when the command isn't installed yet."
How do you clean orphan packages on Arch?
Orphans are dependencies no longer required by any explicitly installed package:
pacman -Qtd
pacman -Qtdq | sudo pacman -Rns -Also clear stale cache periodically:
sudo pacman -ScA strong answer is:
"I list orphans with pacman -Qtd and remove them with Qtdq piped to pacman -Rns. I also run -Sc to trim /var/cache/pacman/pkg/."
Troubleshooting
| Symptom | Likely cause | What to try |
|---|---|---|
failed to synchronize databases |
Mirror down or no network | Check connectivity; try -Syy; switch mirror in /etc/pacman.d/mirrorlist |
pacman: command not found |
Wrong distro (Debian/Ubuntu, RHEL, …) | Install on Arch-based systems; use apt or dnf elsewhere |
| Partial upgrade / dependency errors | Installed without -u after -Sy |
Full pacman -Syu; never -Sy then install alone |
invalid or corrupted package |
Bad download or keyring | pacman -Scc; pacman-key --refresh-keys; retry |
database file exists / lock |
Another pacman running | Wait or remove /var/lib/pacman/db.lck if no pacman process |
| File conflict on upgrade | Overwritten local files | Read prompt; last resort pacman -Syu --overwrite per file glob |
References
- Pacman — Arch Wiki — workflows and best practices
- pacman.conf(5) — man.archlinux.org — repository configuration

