Commonly used “sudo pacman” commands on Arch Linux
“sudo pacman” is the core command for managing software (installing, updating, removing packages) with administrative privileges.
What
is sudo
pacman?
pacman= Arch Linux’s official package manager (stands for Package Archive Manager).sudo= Runspacmanwith root/administrator permissions (required for system-wide changes like installing/removing software).
Core
Functions of sudo
pacman
1. Update the system (critical first step after installation!)
Syncs your local package database with remote servers and updates all installed packages to the latest versions:
sudo
pacman -Syu
-S: Sync (download/install packages)-y: Refresh the package database (yes to sync)-u: Upgrade all out-of-date packages (upgrade)
Always run this before installing new software to avoid dependency conflicts!
2. Install a package
Install one or more packages from Arch’s official repositories:
#
Install a single package (e.g., VLC media player)
sudo
pacman -S vlc
#
Install multiple packages at once (e.g., VLC + GIMP)
sudo
pacman -S vlc gimp
-S: Stands for Sync (the main flag for installing from repos).
3. Remove a package
Delete a package (and optionally its unused dependencies):
#
Basic remove (keeps dependencies)
sudo
pacman -R vlc
#
Remove package + unused dependencies (recommended)
sudo
pacman -Rns vlc
-R: Remove-n: Remove configuration files (nuke configs)-s: Remove unused dependencies (sweep)
4. Search for a package
Find packages in the official repos
#
Search for a package by name/keyword (e.g., "firefox")
pacman
-Ss firefox
#
Search for already installed packages only
pacman
-Qs firefox
-Ss: Search sync database (remote repos)-Qs: Query search (local installed packages)
5. Check package details
See info about a package (version, description, dependencies):
#
Info about a remote package (not installed yet)
pacman
-Si vlc
#
Info about an installed package
pacman
-Qi vlc
-Si: Sync info (remote)-Qi: Query info (local)
6. Clean up cached packages
Pacman
stores downloaded package files (*.pkg.tar.zst)
in /var/cache/pacman/pkg/—clean
them to free space:
#
Delete old cached packages (keep latest version)
sudo
pacman -Sc
#
Delete ALL cached packages (more aggressive)
sudo
pacman -Scc
-Sc: Sync clean (safe)-Scc: Sync clean completely (use if low on disk space)
7. Fix broken dependencies
If you get "dependency error" messages, repair the package database:
sudo
pacman -Syyu --overwrite '*'
-yy: Force refresh the package database (twice = full sync)--overwrite '*': Fixes issues where files are owned by multiple packages (use carefully!).
Notes for Beginners
Never use
pacman -Syalone (it only syncs the database, not upgrades packages)—always use-Syuto update safely.Official repos vs AUR:
pacmanonly works with Arch’s official repos (e.g., core, extra, community). For AUR packages (like Popcorn Time), useyay/pamac(which wrappacman).No
sudofor read-only actions: Commands likepacman -Ss,pacman -Qidon’t needsudo(they only read data, not modify the system).
Summary
sudo pacman -Syu: Update your entire system (most important command).sudo pacman -S <package>: Install a package from official repos.sudo pacman -Rns <package>: Uninstall a package + clean up dependencies/configs.pacman -Ss <keyword>: Search for packages (no sudo needed).sudo pacman -Sc: Clean cached packages to free space.
沒有留言:
張貼留言