Managing packages efficiently is a cornerstone of any Arch Linux user’s workflow. Rather than digging through lengthy man pages, the following guide highlights the most important pacman
commands you’ll use in 99% of scenarios.
1. pacman -S <package>
– Install a Package
Sync and install the specified package along with its dependencies.
sudo pacman -S lynx
2. pacman -Sy
– Refresh Package Databases
Updates the local indexes from remote repositories (core
, extra
, community
).
sudo pacman -Sy
Combine this with installation in one step:
sudo pacman -Sy lynx
3. pacman -Syu
– Full System Upgrade
Synchronize databases and update all packages to the latest versions.
sudo pacman -Syu
4. pacman -Sl
– List All Available Packages
Displays every package in the repositories; useful for browsing or searching.
sudo pacman -Sl | less
5. pacman -Sw <package>
– Download Only
Fetches the package file without installing it—handy for inspecting or transferring to another system.
6. pacman -R <package>
– Remove a Package
Uninstalls the specified package but leaves its dependencies intact.
7. pacman -Rc
or pacman -Rs
– Cascade Removals
-Rc
: Removes a package and its dependents.-Rs
: Removes a package and any unused dependencies.
Combine both (-Rcs
) to remove everything related.
8. pacman -Ql <package>
– List Package Files
Shows all installed files for the specified package, including libraries, binaries, and docs.
9. pacman -Qu
– List Out-of-Date Packages
Displays installed packages that have newer versions available.
sudo pacman -Qu | less
10. pacman -Qi
/ pacman -Si
– View Package Info
-Qi
: Info about an installed package.-Si
: Info about a package in the repository.
11. pacman -U <file>
– Manual Package Upgrade
Installs a specific local package file, replacing any existing installation cleanly.
12. pacman -Qk
– Verify File Integrity
Checks whether all files belonging to installed packages are present and intact.
13. pacman -Dk
/ pacman -Dkk
– Database Integrity Checks
-Dk
: Checks package database consistency.-Dkk
: Reports missing dependencies.
Why These Commands Matter
- Consistency & Safety: Regular use of
pacman -Syu
ensures a cohesive, up-to-date system—Arch doesn’t support partial upgrades. - Efficient Cleanup: Remove unused files and dependencies with the
-Rs
or-Rcs
options to keep your system lean. - Validation & Troubleshooting: Commands like
-Qk
,-Qi
, and-Dkk
help you diagnose missing files or broken packages swiftly.
Sample pacman Cheat Sheet
Purpose | Command |
---|---|
Sync & install | sudo pacman -S <package> |
Refresh databases | sudo pacman -Sy |
Full upgrade | sudo pacman -Syu |
List all packages | sudo pacman -Sl | less |
Download only | sudo pacman -Sw <package> |
Remove package | sudo pacman -R <package> |
Remove with deps | sudo pacman -Rs <package> |
List installed files | pacman -Ql <package> |
Check outdated | pacman -Qu | less |
Installed info | pacman -Qi <package> |
Repo info | pacman -Si <package> |
Manual install | pacman -U /path/to/pkg.tar.zst |
Verify files | pacman -Qk |
Check DB | pacman -Dk / -Dkk |
Tips for Smart Usage
- Use
--needed
to avoid reinstalling already-installed packages unnecessarily. - Chain commands: For example,
pacman -Syu --noconfirm
for scripted updates. - Check orphans: Remove unnecessary orphaned packages:
pacman -Qdtq | pacman -Rns -
- Backup before upgrading: Use tools like
timeshift
or Btrfs snapshots to protect your system.
Conclusion
These core pacman
commands cover the essentials: installation, updates, removal, and verification. With them, you’ll be well-equipped to maintain a safe, clean, and efficient Arch Linux system—without being overwhelmed by rarely-used options.
Study these commands, apply them regularly, and add advanced techniques (like hook scripts or custom queries) as you grow more confident.