Master Linux Package Managers: dpkg, apt, rpm, yum & dnf Commands Explained
This guide introduces the most common Linux package management tools—dpkg, apt, rpm, yum, and dnf—explaining their purposes, supported distributions, core command‑line options, and practical examples for installing, updating, querying, and removing software packages.
Package management systems not only install software but also provide tools to update installed packages, ensuring that code is reviewed and versions are approved by maintainers.
dpkg
Ubuntu, Debian
dpkgis the low‑level utility used by Debian‑based systems to install, create, and manage software packages.
Command line usage
# dpkg [options] [command]
$ dpkg --help
# Options
-i install a package
-r remove a package
-P purge package and its config files
-L list files belonging to a package
-l list installed packages
--unpack unpack a .deb file
-c list files in a package
--configure configure a package
# Parameters
.deb the Debian package file # Install a package
$ dpkg -i package.deb
# Remove a package
$ dpkg -r package
# Purge a package
$ dpkg -P package
# List files of a package
$ dpkg -L package
# Show installed packages
$ dpkg -l
# Unpack a .deb file
$ dpkg --unpack package.deb
# Search for a file in packages
$ dpkg -S keyword
# List all installed packages
$ dpkg -l
# List contents of a .deb file
$ dpkg -c package.deb
# Configure a package
$ dpkg --configure package
# Query installed packages
$ sudo dpkg-query -l
$ sudo dpkg-query -l | less
$ sudo dpkg-query -l | grep tmuxapt
Ubuntu, Debian
apt-getis the high‑level package manager for Debian‑based distributions. It works with .deb packages, similar to Windows installers.
Command line usage
# apt-get [options] command
$ apt --help
# Options
-c specify configuration file
# Parameters
command operation on APT packages
package target package name # Update all installed packages
$ apt-get upgrade
# Full distribution upgrade
$ apt-get dist-upgrade
# Refresh package lists
$ apt-get update
# Install a new package
$ apt-get install packagename
# Remove a package but keep config files
$ apt-get remove packagename
# Purge a package and its config files
$ apt-get --purge remove packagename
# Clean downloaded package files
$ apt-get autoclean apt
# Remove all cached package files
$ apt-get clean
# List installed packages
$ sudo apt list --installed
$ sudo apt list --installed | less
$ sudo apt list --installed | grep tmuxrpm
RHEL, CentOS
rpmis the Red Hat Package Manager used by RPM‑based distributions. It follows the GPL and is widely adopted.
Command line usage
# rpm [OPTION...]
$ rpm --help
# Options
-a query all packages
-c list configuration files (requires -l)
-d list documentation files (requires -l)
-e erase a package
-f query package owning a file
-h display hash marks while installing
-i install a package
-l list files in a package
-p query a package file
-q query mode
-R display package dependencies
-s show file status (requires -l)
-U upgrade a package
-v verbose output
-vv very verbose output
# Parameter
package the RPM file to act upon # Install a package
$ rpm -ivh your-package.rpm
# Force install
$ rpm --force -ivh your-package.rpm
# Remove a package
$ rpm -e proftpd-1.2.8
# List all installed packages
$ rpm -qa
$ rpm -qa | grep sql
# List files installed by a package
$ rpm -ql your-package.rpm
# Find which package provides a file
$ rpm -qf `which program`
# Show detailed info about a package
$ rpm -qif `which program`
# List files of a package
$ rpm -qlf `which program`yum
CentOS 6, CentOS 7
yumis a front‑end to rpm used on Fedora, Red Hat and SUSE. It resolves dependencies automatically and can download packages from configured repositories.
Command line usage
# yum [options] COMMAND
$ yum --help
# Options
-h show help
-y assume yes to all prompts
-c specify config file
-q quiet mode
-v verbose mode
-d debug level (0‑10)
-e error level (0‑10)
-R max wait time for a command
-C run entirely from cache
# Parameters
install install an rpm package
update update an rpm package
check-update check for available updates
remove delete a package
list display package information
search search package information
info show package description
clean clean cached data
shell enter yum shell
resolvedep show package dependencies
localinstall install a local rpm file
localupdate update a local rpm file
deplist list all dependencies # Install a package
$ yum install package1
# Install a group
$ yum groupinstall group1
# Update all packages
$ yum update
# Update a specific package
$ yum update package1
# Check for updates
$ yum check-update
# Upgrade a package
$ yum upgrade package1
# List installed packages
$ yum list installed | grep mysql
# Show package info
$ yum info package1
# Remove a package
$ yum remove package1
# Clean cached packages
$ yum clean packages
$ yum clean headers
$ yum clean oldheadersdnf
RHEL 8, CentOS 8
dnfreplaces yum in newer RPM‑based systems. It uses libsolv for dependency resolution and is written in Python.
Command line usage
# dnf [options] command
$ dnf --help
# Common commands
install install a package
update update packages
upgrade upgrade packages
check-update check for updates
remove/erase delete a package
autoremove remove orphaned packages
clean all clean all cached data
repolist list enabled repositories
repolist all list all repositories
list list packages
list installed list installed packages
list available list installable packages
search search packages
provides find which package provides a file
info show package details
grouplist list package groups
groupinstall install a group
groupupdate update a group
groupremove remove a group
reinstall reinstall a package
downgrade downgrade a package
history show command history
help show help for a command # Install a package
$ dnf install nano
# Upgrade a package
$ dnf update systemd
# Upgrade all packages
$ dnf upgrade
# Check for updates
$ dnf check-update
# Remove a package
$ dnf remove nano
# Clean all caches
$ dnf clean all
# List enabled repositories
$ dnf repolist
# List all repositories
$ dnf repolist all
# List all RPM packages
$ dnf list
# List installed RPM packages
$ dnf list installed
# Search for a package
$ dnf search nano
# Show package info
$ dnf info nano
# Install a group
$ dnf groupinstall 'Educational Software'
# Update a group
$ dnf groupupdate 'Educational Software'
# Remove a group
$ dnf groupremove 'Educational Software'
# Reinstall a package
$ dnf reinstall nano
# Downgrade a package
$ dnf downgrade acpid
# View command history
$ dnf historySigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
