Getting started with pacman
Getting Started with pacman on Arch Linux Distributions
Pacman is Arch Linux’s native package manager, engineered to be both lightweight and powerful. After installing Arch, the first priority is to keep pacman and the system up‑to‑date and to fine‑tune the mirror list for optimal download speeds. This guide walks you through the core tasks every new user should know: updating, searching, installing, removing, cleaning the cache, and configuring pacman, along with common pitfalls and best practices.
Update the system
sudo pacman -Syu-Ssyncs packages,-yrefreshes the package list, and-uupgrades all out‑of‑date packages.- Run this immediately after a fresh install to pull in the latest packages and security patches.
- For a forced refresh of the mirror list, use
sudo pacman -Syyu(the doubleyforces a complete database refresh).
Search for packages
pacman -Ss <search-term>-Sssearches the remote repositories.- For detailed information on a specific package, use
pacman -Si <pkg>.
Install packages
sudo pacman -S <package-name>- Pacman automatically resolves dependencies.
- List multiple packages separated by spaces.
- Add
--neededto skip reinstalling packages that are already present.
Remove packages
sudo pacman -R <package-name>-Rremoves the package but leaves its dependencies.-Rsremoves the package and any dependencies that were installed only for it and are no longer needed.-Rnsalso removes configuration files left behind by the package.
Clean the package cache
sudo pacman -Sc-Scremoves all cached versions of packages except the current one.- For a more aggressive cleanup that deletes all cached packages—including the current ones—use
-Scc. Use this with caution.
View package status
pacman -Qi <package-name>- Shows installed package details.
pacman -Qdtlists orphaned dependencies that can be safely removed.
Configure pacman
- Edit
/etc/pacman.confto enable or disable features such asColor,VerbosePkgLists, orParallelDownloads. - Use
pacman-mirrorsto generate a fast mirror list:sudo pacman-mirrors --fasttrack && sudo pacman -Syyu
- Edit
Common troubleshooting
- If a transaction fails, run
pacman -Syyto force a refresh of the package database. - Resolve broken dependencies with
pacman -D --asdeps <pkg>orpacman -D --asexplicit <pkg>. - For a corrupted database, delete
/var/lib/pacman/db.lckand retry.
- If a transaction fails, run
Using the Arch Wiki
- The Arch Wiki’s Pacman page is the definitive reference, covering advanced options, hooks, and the package signing process.
- The “Pacman” section also explains how to use pacman with AUR helpers like
yayorparufor community packages.
Security best practices
- Keep pacman and the system updated to mitigate vulnerabilities.
- Verify package signatures; pacman checks them automatically if the keyring is properly installed (
pacman-key --init && pacman-key --populate archlinux). - Use
pacman -Syu --noconfirmonly in scripts, not interactively, to avoid accidental upgrades.
By mastering these commands and concepts, you can confidently manage software on Arch Linux, maintain system stability, and keep your system secure.