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.
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.
Action | apt (Debian and Ubuntu) | snap (Ubuntu) | pacman (Arch) | dnf (Fedora and RHEL) | portage (Gentoo) |
---|---|---|---|---|---|
Package Management | |||||
Install a Package. | apt install package | snap install package | pacman -S package | dnf install package | emerge --ask package |
Remove a Package. | apt remove package | snap remove package | pacman -R package | dnf erase package | emerge --deselect package |
Update a Package. | apt install --only-upgrade package | snap refresh package | pacman -U package | dnf upgrade package | emerge --ask --update package |
Change a Package’s upstream. | apt -t unstable package | snap refresh package --channel=beta | |||
Disable a Package. | snap disable package | ||||
Enable a Package. | snap enable package | ||||
Mark a Package. | apt install package | pacman -S --asexplicit package | dnf mark install package | emerge --ask package | |
Purge a Package. | apt purge package | snap remove --purge package | pacman -Rs package | emerge --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 package | pacman -S package | dnf reinstall package | emerge --ask --fetchonly --emptytree package | |
Downgrade a Package. | snap revert package | pacman -Suu package | dnf downgrade package | ||
Ignore a Package’s new version. | apt install --no-upgrade package | ||||
Fix a broken Package. | apt install -f package | revdep-rebuild -v package | |||
Remove any unused dependencies. | apt install --autoremove | pacman -Ru | dnf autoremove | emerge --ask --depclean | |
Show all installed Packages. | apt list --installed | snap list | pacman -Qet | dnf list --installed | less /var/lib/portage/world |
Simulate an installation. | apt install -s package | dnf install --setopt=tsflags=test | emerge --ask --pretend package | ||
Package Group Management | |||||
Install a Package group. | pacman -S group | dnf group install group | emerge --ask @group | ||
Uninstall a Package group. | pacman -R group | dnf group remove group | emerge --deselect @group | ||
Display the available groups. | dnf group | ls /etc/portage/sets | |||
Display a group’s details. | pacman -Sg | dnf 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 update | dnf check-update | emerge --sync | ||
Reload the Package repository. | pacman -Syc | emerge-webrsync | |||
Check the Package repository. | pacman -Dk | dnf check | |||
Add a new repository source. | nano /etc/apt/sources.list | nano /etc/pacman.conf | eselect repository enable repository | ||
Remove a repository source. | nano /etc/apt/sources.list | nano /etc/pacman.conf | eselect repository disable repository | ||
Show the active repositories. | less /etc/apt/sources.list | snap info package | less /etc/pacman.conf | dnf repolist --enabled | eselect repository list |
System Management | |||||
Check for Package updates. | dnf check-update package | ||||
Update all the Packages. | apt upgrade | snap refresh | pacman -Syu | dnf upgrade | emerge --ask --update --deep --newuse @world |
Update the system Packages. | apt dist-upgrade | dnf upgrade-minimal | |||
Simulate a full system update. | apt -s dist-upgrade | dnf upgrade --setopt-tsflags=test | emerge --ask --update --deep --newuse --pretend @world | ||
Reconfigure a Package. | apt install -f | pacman -S package | |||
Enter the Package Manager’s shell. | snap run --shell | dnf shell | |||
Print the current update advisories. | dnf updateinfo --info | eselect news help | |||
Dependency Management | |||||
Check a Package’s dependencies. | apt-cache depends package | pacman -T package | dnf repoquery --deplist package | ||
Print the Package’s dependency tree. | pactree package | dnf repoquery --tree package | emerge --ask --deep --tree package | ||
Skip dependency resolution. | apt install --no-install-recommends package | pacman -Sd package | emerge --ask --nodeps package | ||
Skip GPG checking. | dnf install --nogpgcheck package | ||||
Searching | |||||
Basic Package search. | apt search package | snap find package | pacman -Qs package | dnf search package | emerge --search package |
Regex Package search. | apt search ^package* | pacman -Qs ^package* | emerge --search ^package* | ||
Filename search. | pacman -F filename | dnf provides filename | equery b filename | ||
Display a Package’s info. | apt-cache showpkg package | snap info package | pacman -Qi package | dnf info package | equery m package |
Print the contents of a package. | snap info --verbose package | pacman -Ql package | equery f package | ||
Print the changelog of a package. | apt-get changelog package | snap info --verbose package | pacman -Qc package | dnf repoquery --changelogs | equery c package |
Print all duplicate packages. | dnf repoquery --duplicates | ||||
Print all external packages. | pacman -Qm |
Image credit: Unsplash. All alterations by Ramces Red.
Our latest tutorials delivered straight to your inbox