pacman
Updated: September 28, 2024
Pacman is the package manager for Arch and Manjaro distros of Linux.
OPERATIONS
-D, --database # operate on the package database. can also check for internal consistancy.
-Q, --query # query the package database. view packages and thier files, queries can be filtered.
-R, --remove # remove packages from the system. groups can be specified, every package in that group would be removed.
-S, --sync # synchronize packages. packages are installed directly from remote repos.
-T, --deptest # check dependencies. (operation accepts no other options)
-U, --upgrade # upgrade or add a package to the system and install required dependencies from sync repos.
-F, --files # query the files database. operation allows looking for packages owning certain files. only packages part of your sync database are searched.
-V, --version # display version number.
-h, --help # display syntax for the given operation.
ARGUMENTS
Arguments vary according to the Operation being used.
Updating
sudo pacman -Syu # basic update.
sudo pacman -Syyu # force full refresh. (must do when switching branches or mirrors)
sudo pacman -Syyuu # force full refresh plus allow downgrade of packages. (only needed when switching to older branch)
sudo pacman -Syu --ignore=firefox # keeps an application from updating.
Installing Packages
sudo pacman -Syu package1 # ideal way to install packages.
sudo pacman -U /var/cache/pacman/pkg/smplayer-19.5.0-1-x86_64.pkg.tar.xz # install directly from system.
sudo pacman -U https://mirror.alpix.eu/manjaro/stable/community/x86_64/smplayer-19.5.0-1-x86_64.pkg.tar.xz
pacman -S package1 package2 # not advised to install packages this way. (may lead to partial upgrades)
pacman -S version/package1 # install a certain version.
pacman -Fl <package> # check which files a package not yet installed would and where.
Searching for Packages
pacman -Ss string1 string2 ... # search packages in sync database.
pacman -Fs string1 string2 ... # search packages in file database.
pacman -Qs string1 string2 ... # search for already installed packages.
pacman -Q # list all packages on the system.
pacman -Qc # view change log for installed application.
pacman -Qd # list all packages installed as dependencies.
pacman -Qe # list only packages you have installed. (explicitly)
pacman -Qen # the n makes it so version info is gone, just names of packages. (good for scripts)
pacman -Qet # list explicit packages that have no dependencies.
pacman -Ql # find all files owned by a package.
pacman -Qm # list only AUR packages.
pacman -Qn # list only packages from core. (sync database)
pacman -Qo # check location of binary executable file owned by a package.
pacman -Qu # find packages that need to be updated.
Check for orphaned or dropped packages
pacman -Qtd # check for packages installed as dependency, but no longer used by any packages. If orphaned packages is still needed (not a dependency) change installation reason to explicit. Otherwise, remove it. Run after `pacman -Syu`
sudo pacman -Rs $(pacman -Qdtq) # remove all orphans
pacman -Qm # see packages that are no longer in remote repository.
Download Packages w/o Installing
sudo pacman -Sw smplayer # package and dependencies download to pacman cache `/var/cache/pacman/pkg`
See what packages belong to an app group
pacman -Sg gnome # list packages for gnome group
Remove Packages
sudo pacman -Rsu smplayer # removes package & unneeded dependencies
sudo pacman -Rsun smplayer # removes package, dependencies, and backup config files
pacman -R package_name # remove package & leaves dependencies behind
pacman -Rs package_name # remove a package and its dependencies not used by other installed packages.
pacman -Sc # removes all cached packages that have not been installed.
pacman will not remove config files created by the application. (dotfiles in home folder). pacman does save important config files when removing certain applications and names them as .pacsave. To prevent the creation of these backup files use
-n
pacman -Rn package_name
pacman -Rns package # best way to remove a package
Get Info on Package
sudo pacman -Si package # get info on package not on system
sudo pacman -Qi package # get info on package installed on system
Commands to be avoided!!
pacman -Sy # would do a partial install--very bad | always use `pacman -Syu` to upgrade
pacman -Rsc package_name # removes package and all dependencies and all packages that depend on it recursively
pacman -Rdd package_name # removes package required by another package, w/o removing dependent package. skips dependency checks during package removal. As a result, a package providing a critical dependency could be removed, resulting in a broken system.
pacman --overwrite # only use if explicitly told by arch developer
Examples
pacman -Si <package> | egrep -i groups # shows all groups a package belongs to.
Settings
In /etc/pacman.conf
Color # add and comment out monochrome
ILoveCandy # changes progress bar to pacman eating powerpills