Linux Package Manager Cheatsheet

Package Manager Linux Cheatsheet 00 Featured Image

A package manager is the bread and butter of every Linux distribution. It serves as the link between the traditional UNIX system and external third-party programs. It also lets you customize your system for any function and purpose.

At its core, a package manager is a program that adds, removes, and keeps track of any third-party program in your system. Further, it also eases the load of managing programs through version downgrading and calculating dependencies.

Linux Package Manager Cheatsheet Download

Download this Cheatsheet

Enter your email below to receive this PDF cheatsheet in your Inbox.

Essential Package Manager Commands

By default, each major Linux distribution maintains its own custom package manager. Despite that, these utilities often share a number of common functions and commands.

This cheatsheet gives you these necessary commands for your own Linux package manager. This includes the various apt commands in Debian and Ubuntu and pacman in Arch Linux. Not only that, but this cheatsheet will also highlight some of their powerful and unique features.

Actionapt (Debian and Ubuntu)snap (Ubuntu)pacman (Arch)dnf (Fedora and RHEL)portage (Gentoo)
Package Management
Install a Package.apt install packagesnap install packagepacman -S packagednf install packageemerge --ask package
Remove a Package.apt remove packagesnap remove packagepacman -R packagednf erase packageemerge --deselect package
Update a Package.apt install --only-upgrade packagesnap refresh packagepacman -U packagednf upgrade packageemerge --ask --update package
Change a Package’s upstream.apt -t unstable packagesnap refresh package --channel=beta
Disable a Package.snap disable package
Enable a Package.snap enable package
Mark a Package.apt install packagepacman -S --asexplicit packagednf mark install packageemerge --ask package
Purge a Package.apt purge packagesnap remove --purge packagepacman -Rs packageemerge --ask --depclean package
Restore a Package to an older state.snap restore package
Save the current state of a Package.snap save package
Reinstall a Package.apt install --reinstall packagepacman -S packagednf reinstall packageemerge --ask --fetchonly --emptytree package
Downgrade a Package.snap revert packagepacman -Suu packagednf downgrade package
Ignore a Package’s new version.apt install --no-upgrade package
Fix a broken Package.apt install -f packagerevdep-rebuild -v package
Remove any unused dependencies.apt install --autoremovepacman -Rudnf autoremoveemerge --ask --depclean
Show all installed Packages.apt list --installedsnap listpacman -Qetdnf list --installedless /var/lib/portage/world
Simulate an installation.apt install -s packagednf install --setopt=tsflags=testemerge --ask --pretend package
Package Group Management
Install a Package group.pacman -S groupdnf group install groupemerge --ask @group
Uninstall a Package group.pacman -R groupdnf group remove groupemerge --deselect @group
Display the available groups.dnf groupls /etc/portage/sets
Display a group’s details.pacman -Sgdnf group info group
Update a group in the system.dnf group upgrade group
Mark a group for installation.dnf group mark install group
Mark a group for removal.dnf group mark remove group
Repository Management
Update a Package’s upstream.snap switch --channel=beta program
Update the Package repository.apt updatednf check-updateemerge --sync
Reload the Package repository.pacman -Sycemerge-webrsync
Check the Package repository.pacman -Dkdnf check
Add a new repository source.nano /etc/apt/sources.listnano /etc/pacman.confeselect repository enable repository
Remove a repository source.nano /etc/apt/sources.listnano /etc/pacman.confeselect repository disable repository
Show the active repositories.less /etc/apt/sources.listsnap info packageless /etc/pacman.confdnf repolist --enabledeselect repository list
System Management
Check for Package updates.dnf check-update package
Update all the Packages.apt upgradesnap refreshpacman -Syudnf upgradeemerge --ask --update --deep --newuse @world
Update the system Packages.apt dist-upgradednf upgrade-minimal
Simulate a full system update.apt -s dist-upgradednf upgrade --setopt-tsflags=testemerge --ask --update --deep --newuse --pretend @world
Reconfigure a Package.apt install -fpacman -S package
Enter the Package Manager’s shell.snap run --shelldnf shell
Print the current update advisories.dnf updateinfo --infoeselect news help
Dependency Management
Check a Package’s dependencies.apt-cache depends packagepacman -T packagednf repoquery --deplist package
Print the Package’s dependency tree.pactree packagednf repoquery --tree packageemerge --ask --deep --tree package
Skip dependency resolution.apt install --no-install-recommends packagepacman -Sd packageemerge --ask --nodeps package
Skip GPG checking.dnf install --nogpgcheck package
Basic Package search.apt search packagesnap find packagepacman -Qs packagednf search packageemerge --search package
Regex Package search.apt search ^package*pacman -Qs ^package*emerge --search ^package*
Filename search.pacman -F filenamednf provides filenameequery b filename
Display a Package’s info.apt-cache showpkg packagesnap info packagepacman -Qi packagednf info packageequery m package
Print the contents of a package.snap info --verbose packagepacman -Ql packageequery f package
Print the changelog of a package.apt-get changelog packagesnap info --verbose packagepacman -Qc packagednf repoquery --changelogsequery c package
Print all duplicate packages.dnf repoquery --duplicates
Print all external packages.pacman -Qm

Image credit: Unsplash. All alterations by Ramces Red.

Ramces Red
Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox