Update the System
syncs the package databases and upgrades everything in one transaction. Never run on its own and install something afterwards: new packages against old databases is a partial upgrade, and partial upgrades break Arch systems.
| Command | What it does |
|---|---|
| Refresh the databases and upgrade every package | |
| Upgrade the system and install a package in the same safe transaction | |
| Upgrade using the databases you already have, without refreshing | |
| Force-redownload the databases too, after changing mirrors | |
| List pending updates without touching the databases (pacman-contrib) |
Install Packages
| Command | What it does |
|---|---|
| Install a package from the repos | |
| Install several, skipping any already current | |
| Install from a named repo when two repos ship the same package | |
| Install a local package file | |
| Download into the cache only, no install | |
| Let the install overwrite specific conflicting files (targeted glob, never casually) |
Remove Packages
| Command | What it does |
|---|---|
| Remove just the package | |
| Remove it and its now-unneeded dependencies | |
| Also skip the .pacsave config backups; the usual full removal | |
| Cascade: remove it and everything that depends on it (read the list first) | |
| List orphaned dependencies |
Remove every orphan in one go:
pacman -Qdtq | sudo pacman -Rns -Search Packages
| Command | What it does |
|---|---|
| Search the repos by name and description | |
| Search installed packages | |
| Which repo package ships a file ( once first to fetch the file database) | |
| Which installed package owns a file | |
| List the packages in a group |
Package Info
| Command | What it does |
|---|---|
| Repo info: version, size, dependencies | |
| Installed info, including install date, reason, and what requires it | |
| Files the package installed | |
| Dependency tree (pacman-contrib) |
List Installed Packages
| Command | What it does |
|---|---|
| Every installed package with its version | |
| Explicitly installed packages, what you actually asked for | |
| Foreign packages: AUR and local installs | |
| Native packages only, names only | |
| Re-mark it as a dependency so orphan cleanup can take it later | |
| Count them |
Clean the Cache
Every downloaded package stays in until you clean it.
| Command | What it does |
|---|---|
| Delete cached packages that are no longer installed | |
| Empty the whole cache; you lose downgrade-from-cache | |
| Keep the newest 3 versions of each package, delete the rest (pacman-contrib, the better habit) | |
| Keep only the newest version | |
| Downgrade by reinstalling an older version straight from the cache |
Downgrade a Package
pacman has no rollback. You go back by installing an older package file, from your cache or from the Arch Linux Archive.
| Command | What it does |
|---|---|
| See which older versions you still have cached | |
| Install that version over the current one | |
| Install a version that is no longer cached, straight from the archive | |
| Pick a version from cache or the archive interactively (, from the AUR) |
The next pulls the new version straight back. Hold it with in until the upstream bug is fixed, and treat that hold as temporary: a pinned package whose dependencies keep moving is a partial upgrade waiting to happen.
Force and Overwrite
There is no any more; it was split into narrower flags. Use them when you know exactly which file or dependency is in the way.
| Command | What it does |
|---|---|
| Reinstall a package that is already installed, restoring deleted files | |
| Install over untracked files, for the exact paths the error named | |
| Remove without dependency checks, leaving whatever needed it broken | |
| Last resort; ignores every file conflict on the system |
Reinstall every native package, after a half-finished upgrade or a mangled :
sudo pacman -S $(pacman -Qnq)Skip Prompts
| Command | What it does |
|---|---|
| Answer yes to every prompt, for scripts and provisioning | |
| Install unattended, skipping what is already current | |
| Remove without the confirmation | |
| Quieter output for logs and CI |
takes the default answer to every question, and on a replace-this-with-that or pick-a-provider prompt the default is not always the one you want. Keep it for containers and scripts, not for your daily upgrade.
Keyring
| Command | What it does |
|---|---|
| Update the signing keys before a big upgrade on a stale system | |
| Create the keyring on a fresh install | |
| Load the Arch master keys | |
| Pull key updates from a keyserver (slow, and rarely the actual fix) |
When the keyring itself is broken and signatures still fail, rebuild it from scratch:
sudo rm -r /etc/pacman.d/gnupg
sudo pacman-key --init
sudo pacman-key --populate archlinux
sudo pacman -Sy archlinux-keyringMirrors
Mirrors live in and are tried top to bottom. reflector () ranks and rewrites the list; after changing mirrors, run .
sudo reflector --latest 20 --protocol https --sort rate --save /etc/pacman.d/mirrorlistpacman.conf
holds the repositories and pacman's behaviour.
| Setting | What it does |
|---|---|
| Uncomment for coloured output | |
| Download several packages at once | |
| Hold a package back from upgrades | |
| Hold back a whole group | |
| Add it under for the Pac-Man progress bar | |
| Uncomment the section (both lines) for 32-bit packages, e.g. Steam |
Enabling multilib means uncommenting both lines, then refreshing the databases:
[multilib]
Include = /etc/pacman.d/mirrorlistA third-party repo is the same shape, appended at the end of the file, and the lower it sits the lower its priority:
[myrepo]
SigLevel = Optional TrustAll
Server = https://example.com/repo/$archRun after either change. Custom post-install actions go in rather than in this file.
The AUR
pacman itself cannot install from the AUR: the AUR ships build recipes, not packages. A helper builds them and wraps the upgrade.
| Command | What it does |
|---|---|
| Build and install an AUR package (paru works the same) | |
| Full system upgrade including AUR packages | |
| The AUR packages currently installed |
Building by hand, without a helper:
git clone https://aur.archlinux.org/package.git
cd package && makepkg -siyay and paru
Helpers pass repo packages straight to pacman and build AUR ones with makepkg. Install one with the same manual build, since the helper is itself an AUR package:
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay && makepkg -si| Command | What it does |
|---|---|
| Upgrade repo and AUR packages together (plain does the same) | |
| Upgrade only the AUR packages | |
| Search the repos and the AUR at once | |
| Download the PKGBUILD only, to read before you build | |
| Remove build dependencies nothing needs any more | |
| paru's equivalent of ; it shows the PKGBUILD diff by default |
Run helpers as your normal user, never with : they call sudo themselves at the install step, and building as root breaks file ownership. Everything in the AUR is a user submission with no review, so read the PKGBUILD for anything with few votes.
History and Logs
pacman logs every transaction to . There is no like DNF has; rolling back means reinstalling the older package file.
| Command | What it does |
|---|---|
| What pacman did last | |
| Every install, with dates | |
| The last batch of upgrades, to find what broke something | |
| The same, filtered properly (pacman-contrib) | |
| Installed packages ordered by install date |
Flags Explained
pacman flags compose: one capital operation letter plus lowercase modifiers.
| Operation | Modifiers |
|---|---|
| sync (install from repos) | search, info, refresh databases, upgrade, download only, clean cache |
| query installed | search, info, files, owner of file, explicit, foreign, native, orphans |
| remove | unneeded dependencies too, no .pacsave backups, cascade, skip dependency checks |
| install a package file | local path or URL |
| file database | refresh it first |
| change the database | , to change why a package is installed |
Common pacman Errors
| Error | What it means and how to fix it |
|---|---|
| pacman cannot reach the mirrors. Check DNS and the system clock, retry with , then regenerate the mirrorlist with reflector | |
| Your database is older than what the mirror now carries. | |
| Another pacman is running, or one died. Check , then | |
| A file on disk belongs to no package. Find the owner with ; if there is none, move it aside or install with for that exact path | |
| Almost always a stale keyring or a wrong clock, not a bad mirror. Fix the clock, update , then clear the bad download with | |
| / | The keyring does not have the packager's key. Update , or rebuild the keyring |
| The package was renamed, moved to the AUR, or lives in a repo you have not enabled, such as multilib. Search with first | |
| / | Something installed still needs it. shows Required By; remove them together with , or cascade with |
| Everything you asked for is already installed and current | |
| on | The package cache filled the partition. , then |
pacman, apt and dnf
The same tasks on Debian and Ubuntu are in the apt cheat sheet, and on RHEL and Fedora in the DNF cheat sheet.
| Task | pacman | apt | dnf |
|---|---|---|---|
| Refresh and upgrade | |||
| Install | |||
| Remove with dependencies | |||
| Search | |||
| Who owns a file | |||
| List installed | |||
| Clean cache |
Gotchas
- Partial upgrades break Arch. Either or nothing; never followed by an install later, and that includes an AUR helper refreshing the databases for you.
- When you have edited a config file, pacman writes the new default next to it as instead of overwriting. Merge them after upgrades with (pacman-contrib), or at least look for them: .
- Signature errors after months without updates mean a stale keyring, not corrupt mirrors: .
- Downloads crawling is nearly always the mirrorlist, not pacman. Re-rank with reflector and raise in .
- Queries need no root. , , , and all run as a normal user; only , , and need sudo.
- Manjaro holds Arch packages back about two weeks, so AUR builds that assume Arch-current libraries can fail there on version skew alone.
- MSYS2 on Windows uses pacman with its own repositories: the flags on this page work, the Arch repos and the AUR do not.