Pacman Cheatsheet

Pacman/Rosetta

< PacmanJump to navigationJump to search

This page uses a table to display the correspondence of package management commands among some of the most popular Linux distributions. The original inspiration was given by openSUSE's Software Management Command Line Comparison.

Tip: Arch users having to temporarily deal with another Linux distribution can use pacapt, a simple wrapper around other package managers.Note:

  • Some of the tools described here are specific to a certain version of pacman. The -Qk option is new in pacman 4.1.

Contents

Basic operations

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Install a package(s) by namepacman -Sdnf installapt installzypper install
zypper in
emerge [-a]
Remove a package(s) by namepacman -Rsdnf removeapt removezypper remove
zypper rm
emerge -vc
Search for package(s) by searching the expression in name, description, short description. What exact fields are being searched by default varies in each tool. Mostly options bring tools on par.pacman -Ssdnf searchapt searchzypper search
zypper se [-s]
emerge -S
Upgrade Packages - Install packages which have an older version already installedpacman -Syudnf upgradeapt update && apt upgradezypper update zypper upemerge -uDN @world
Upgrade Packages - Another form of the update command, which can perform more complex updates -- like distribution upgrades. When the usual update command will omit package updates, which include changes in dependencies, this command can perform those updates.pacman -Syudnf distro-syncapt update && apt dist-upgradezypper dupemerge -uDN @world
Clean up all local caches. Options might limit what is actually cleaned. Autoclean removes only unneeded, obsolete information.pacman -Sc
pacman -Scc
dnf clean allapt autoclean
apt clean
zypper cleaneclean distfiles
Remove dependencies that are no longer needed, because e.g. the package which needed the dependencies was removed.pacman -Qdtq | pacman -Rs -dnf autoremoveapt autoremovezypper rm -uemerge --depclean
Remove packages no longer included in any repositories.pacman -Qmq | pacman -Rs -dnf repoquery --extrasaptitude purge '~o'
Mark a package previously installed as a dependency as explicitly required.pacman -D --asexplicitdnf mark installapt-mark manualemerge --select
Install package(s) as dependency / without marking as explicitly required.pacman -S --asdepsdnf install => dnf mark removeapt-mark autoemerge -1
Only downloads the given package(s) without unpacking or installing thempacman -Swdnf downloadapt install --download-only (into the package cache)
apt download (bypass the package cache)
zypper --download-onlyemerge --fetchonly
Start a shell to enter multiple commands in one sessionapt-config shellzypper shell
Show a log of actions taken by the software management.cat /var/log/pacman.logdnf historycat /var/log/dpkg.logcat /var/log/zypp/historylocated in /var/log/portage
Get a dump of the whole system information - Prints, Saves or similar the current state of the package management system. Preferred output is text or XML. (Note: Why either-or here? No tool offers the option to choose the output format.)(see /var/lib/pacman/local)(see /var/lib/rpm/Packages)apt-cache statsn/aemerge --info
e-mail delivery of package changesapt install apt-listchanges
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Querying specific packages

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Show all or most information about a package. The tools' verbosity for the default command vary. But with options, the tools are on par with each other.pacman -[S|Q]idnf list, dnf infoapt show / apt-cache policyzypper info zypper ifemerge -S; emerge -pv; eix
Display local package information: Name, version, description, etc.pacman -Qirpm -qi / dnf info installeddpkg -s / aptitude showzypper info; rpm -qiemerge -pv and emerge -S
Display remote package information: Name, version, description, etc.pacman -Sidnf infoapt-cache show / aptitude showzypper infoemerge -pv and emerge -S or equery m (meta)
Display files provided by local packagepacman -Qlrpm -qldpkg -Lrpm -Qlequery files; qlist
Display files provided by a remote packagepacman -Fldnf repoquery -l or repoquery -l (from package yum-utils)apt-file list $patternpfl
Query the package which provides FILEpacman -Qorpm -qf (installed only) or dnf provides (everything) or repoquery -f (from package yum-utils)dpkg -S / dlocatezypper search -fequery belongs; qfile
List the files that the package holds. Again, this functionality can be mimicked by other more complex commands.pacman -Ql
pacman -Fl
dnf repoquery -ldpkg-query -Lrpm -qlequery files; qlist
Displays packages which provide the given exp. aka reverse provides. Mainly a shortcut to search a specific field. Other tools might offer this functionality through the search command.pacman -Fodnf providesapt-file searchzypper what-provides zypper wpequery belongs (only installed packages); pfl
Search all packages to find the one which holds the specified file. auto-apt is using this functionality.pacman -Fsdnf providesapt-file searchzypper search -fequery belongs; qfile
Show the changelog of a packagepacman -Qcrpm -q --changelogapt-get changelogrpm -q --changelogequery changes -f
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Querying package lists

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Search for package(s) by searching the expression in name, description, short description. What exact fields are being searched by default varies in each tool. Mostly options bring tools on par.pacman -Ssdnf searchapt searchzypper search zypper se [-s]emerge -S; eix
Lists packages which have an update available. Note: Some provide special commands to limit the output to certain installation sources, others use options.pacman -Qudnf list updates, dnf check-updateapt-get upgrade -> nzypper list-updates zypper patch-check (just for patches)emerge -uDNp @world
Display a list of all packages in all installation sources that are handled by the packages management. Some tools provide options or additional commands to limit the output to a specific installation source.pacman -Sldnf list availableapt-cache dumpavail apt-cache dump (Cache only) apt-cache pkgnameszypper packagesportageq all_best_visible /
Generates a list of installed packagespacman -Qdnf list installeddpkg --list | grep ^izypper search --installed-onlyqlist -IC
List packages that are installed but are not available in any installation source (anymore).pacman -Qmdnf list extrasdeborphanzypper se -si | grep 'System Packages'eix-test-obsolete
List packages that were recently added to one of the installation sources, i.e. which are new to it.(none)dnf list recentaptitude search '~N' / aptitude forget-newn/aeix-diff
List installed local packages along with versionpacman -Qrpm -qadpkg -lzypper search -s; rpm -qaqlist -ICv
Search locally installed package for names or descriptionspacman -Qsrpm -qa '*<str>*'aptitude search '~i(~n $name|~d $description)'eix -S -I
List packages not required by any other packagepacman -Qtdnf leavesdeborphan -anp1emerge -pc
List packages installed explicitly (not as dependencies)pacman -Qednf history userinstalledapt-mark showmanualemerge -pvO @selected; eix --selected
List packages installed automatically (as dependencies)pacman -Qdapt-mark showauto
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Querying package dependencies

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Display packages which require X to be installed, aka show reverse dependencies.pacman -Siidnf repoquery --alldeps --whatrequires or repoquery --whatr[equires]apt-cache rdepends / aptitude search ~D$patternzypper search --requiresemerge -pvc
Display packages which conflict with given expression (often package). Search can be used as well to mimic this function.dnf repoquery --conflictsaptitude search '~C$pattern'
List all packages which are required for the given package, aka show dependencies.pacman -[S|Q]idnf repoquery --requires or repoquery -Rapt-cache depends / apt-cache showzypper info --requiresemerge -ep
List what the current package providesdnf providesdpkg -s / aptitude showzypper info --providesequery files; qlist
List all packages that require a particular packagednf repoquery --alldeps --whatrequiresaptitude search ~D{depends,recommends,suggests}:$pattern / aptitude whyzypper search --requiresequery depends -a
Display all packages that the specified packages obsoletes.dnf list obsoletesapt-cache show
Generates an output suitable for processing with dotty for the given package(s).apt-cache dottyn/a
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Installation sources management

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Installation sources management${EDITOR} /etc/pacman.conf${EDITOR} /etc/yum.repos.d/${REPO}.repo${EDITOR} /etc/apt/sources.list${EDITOR} /etc/zypp/repos.d/${REPO}.repolayman; eselect repository
Add an installation source to the system. Some tools provide additional commands for certain sources, others allow all types of source URI for the add command. Again others, like apt and dnf force editing a sources list. apt-cdrom is a special command, which offers special options design for CDs/DVDs as source./etc/pacman.conf/etc/yum.repos.d/*.repoapt-cdrom addzypper service-addlayman, overlays
Refresh the information about the specified installation source(s) or all installation sources.pacman -Sy (always upgrade the whole system afterwards)dnf clean expire-cache && dnf check-updateapt-get updatezypper refresh zypper refemerge --sync;layman -S
Prints a list of all installation sources including important information like URI, alias etc.cat /etc/pacman.d/mirrorlistcat /etc/yum.repos.d/*apt-cache policyzypper service-listlayman -l; eselect repository list
List all packages from a certain repopaclist <repo> eix --in-overlay
Disable an installation source for an operationdnf --disablerepo=emerge package::repo-to-use
Download packages from a different version of the distribution than the one installed.dnf --releasever=apt-get install -t release package/ apt-get install package/release (deps not covered)echo "category/package ~amd64" >> /etc/portage/package.keywords && emerge package
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Overrides

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Add a package lock rule to keep its current state from being changed/etc/pacman.conf
modify IgnorePkg array
dnf.conf <--”exclude” option (add/amend)apt-mark hold pkgPut package name in /etc/zypp/locks, or zypper al/etc/portage/package.mask
Delete a package lock ruleremove package from IgnorePkg line in /etc/pacman.confapt-mark unhold pkgRemove package name from /etc/zypp/locks or zypper rl/etc/portage/package.mask (or package.unmask)
Show a listing of all lock rulescat /etc/pacman.conf/etc/apt/preferencesView /etc/zypp/locks or zypper llcat /etc/portage/package.mask
Set the priority of the given package to avoid upgrade, force downgrade or to overwrite any default behavior. Can also be used to prefer a package version from a certain installation source.${EDITOR} /etc/pacman.conf
Modify HoldPkg and/or IgnorePkg arrays
/etc/apt/preferences, apt-cache policyzypper mr -p${EDITOR} /etc/portage/package.accept_keywords
Add a line with =category/package-version
Remove a previously set priority/etc/apt/preferenceszypper mr -p${EDITOR} /etc/portage/package.accept_keywords
remove offending line
Show a list of set priorities.apt-cache policy /etc/apt/preferenceszypper lr -pgrep -r . /etc/portage/package.accept_keywords
Ignores problems that priorities may trigger.n/a
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Verification and repair

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Verify single packagepacman -Qk[k]rpm -Vdebsumsrpm -Vequery check
Verify all packagespacman -Qk[k]rpm -Vadebsumsrpm -Vaequery check
Reinstall given Package - Will reinstall the given package without dependency hassle.pacman -Sdnf reinstallapt install --reinstallzypper install --forceemerge -1O
Verify dependencies of the complete system. Used if installation process was forcefully killed.pacman -Dkdnf repoquery --requiresapt-get checkzypper verifyemerge -uDN @world
Use some magic to fix broken dependencies in a systempacman dep level - pacman -Dk, shared lib level - findbrokenpkgs or lddddnf repoquery --unsatisfiedapt-get --fix-broken
aptitude install
zypper verifyrevdep-rebuild
Add a checkpoint to the package system for later rollback(unnecessary, done on every transaction)n/a
Remove a checkpoint from the systemN/AN/An/a
Provide a list of all system checkpointsN/Adnf history listn/a
Rolls entire packages back to a certain date or checkpoint.N/Adnf history rollbackn/a
Undo a single specified transaction.N/Adnf history undon/a
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo

Using package files and building packages

ActionArchRed Hat/FedoraDebian/UbuntuSLES/openSUSEGentoo
Query a package supplied on the command line rather than an entry in the package management databasepacman -Qprpm -qpdpkg -I
List the contents of a package filepacman -Qplrpmls rpm -qpldpkg -crpm -qpl
Installs local package file, e.g. app.rpm and uses the installation sources to resolve dependenciespacman -Udnf installapt installzypper inemerge
Updates package(s) with local packages and uses the installation sources to resolve dependenciespacman -Udnf upgradedebiemerge
Add a local package to the local package cache mostly for debugging purposes.cp $filename /var/cache/pacman/pkg/apt-cache addn/acp $filename /usr/portage/distfiles
Extract a packagetar -Jxvfrpm2cpio | cpio -viddpkg-deb -xrpm2cpio | cpio -vidtar -jxvf
Install/Remove packages to satisfy build-dependencies. Uses information in the source package.Use ABS && makepkg -seocdnf builddepapt-get build-depzypper si -demerge -o
Display the source package to the given package name(s)dnf repoquery -sapt-cache showsrcn/a
Downloads the corresponding source package(s) to the given package name(s)Use ABS && makepkg -odnf download --sourceapt-get source / debcheckoutzypper source-installemerge --fetchonly
Build a packagemakepkg -srpmbuild -ba (normal)
mock (in chroot)
debuildrpmbuild -ba; build; osc buildebuild; quickpkg
Check for possible packaging issuesnamcaprpmlintlintianrpmlintrepoman
ActionArchRed Hat/FedoraDebian/UbuntuSUSE/openSUSEGentoo


You'll only receive email when they publish something new.

More from Don Palmigiano
All posts