Master Linux Package Managers: dpkg, apt, rpm, yum, and dnf Explained
This guide introduces the most common Linux package managers—dpkg, apt, rpm, yum, and dnf—explaining their purpose, core commands, options, and practical examples so readers can install, update, query, and remove software across Debian‑based and Red Hat‑based distributions.
Package management systems not only install software but also provide tools to update already installed packages. Repositories help ensure that the code used on your system has been reviewed and that package versions are approved by developers and maintainers.
1. dpkg
Ubuntu, Debian
dpkgis the utility used by Debian‑based systems to install, create, and manage software packages.
Command line usage
# dpkg(option)(parameter)
$ dpkg --help
Usage: dpkg [<option> ...] <command>
# Options
-i: install package
-r: remove package
-P: purge package and its configuration files
-L: list files belonging to a package
-l: list installed packages
--unpack: unpack a package
-c: list files in a package
--configure: configure a package
# Parameters
.deb package: the .deb file to operate onExample commands
# install a package
$ dpkg -i package.deb
# remove a package
$ dpkg -r package
# purge a package (including config files)
$ dpkg -P package
# list files belonging to a package
$ dpkg -L package
# show package version
$ dpkg -l package
# 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 tmux2. apt
Ubuntu, Debian
apt-get(often invoked as apt) is the APT package management tool used by Debian‑based distributions.
Command line usage
# apt-get(option)(parameter)
$ apt --help
Usage: apt [options] command
# Options
-c: specify configuration file
# Parameters
command: manage APT packages (install, remove, update, etc.)
package: the target package nameExample commands
# update package lists
$ apt-get update
# upgrade all installed packages
$ apt-get upgrade
# distribution upgrade
$ apt-get dist-upgrade
# install a new package
$ apt-get install packagename
# remove a package but keep config files
$ apt-get remove packagename
# purge a package (remove config files)
$ apt-get --purge remove packagename
# clean downloaded package files
$ apt-get autoclean
$ apt-get clean
# list installed packages
$ sudo apt list --installed
$ sudo apt list --installed | less
$ sudo apt list --installed | grep tmux3. rpm
RHEL, CentOS
rpmis the Red Hat Package Manager used to manage RPM packages on Red Hat‑based systems.
Command line usage
# rpm(option)(parameter)
$ rpm --help
Usage: rpm [OPTION...]
# Options
-a: query all packages
-c: list configuration files (used with "-l")
-d: list documentation files (used with "-l")
-e<package> or --erase <package>: erase a package
-f<file>: query which package owns a file
-h or --hash: display package header hash
-i: display package information
-i<package> or --install <package>: install a package
-l: list files in a package
-p<package>: query a package file
-q: query mode (asks before actions)
-R: display package relationships
-s: show file status (used with "-l")
-U<package> or --upgrade <package>: upgrade a package
-v: verbose output
-vv: very verbose (useful for debugging)
# Parameters
package: the RPM package to operate onExample commands
# install a package
$ rpm -ivh your-package.rpm
# force installation
$ rpm --force -ivh your-package.rpm
# uninstall a package
$ rpm -e proftpd-1.2.8
# list all installed packages
$ rpm -qa
$ rpm -qa | grep sql
# list files from an installed package
$ rpm -ql your-package.rpm
# list files from an uninstalled package file
$ rpm -qlp your-package.rpm
# find which package provides a program
$ rpm -qf `which program`
$ rpm -qif `which program`
$ rpm -qlf `which program`4. yum
CentOS 6, CentOS 7
yumis the front‑end package manager for RPM‑based distributions such as Fedora, Red Hat, and SUSE.
Command line usage
# yum(option)(parameter)
$ yum --help
Loaded plugins: fastestmirror, langpacks
Usage: yum [options] COMMAND
# Options
-h: show help
-y: answer 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: set maximum 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 metadata
info: show detailed package description
clean: clean cached data
shell: enter yum shell
resolvedep: show package dependencies
localinstall: install a local RPM
localupdate: update a local RPM
deplist: list all dependencies of a packageExample commands
# install a package
$ yum install package1
$ yum groupinstall group1
# update all packages
$ yum update
$ yum update package1
$ yum check-update
$ yum upgrade package1
$ yum groupupdate group1
# query installed packages
$ yum list installed | grep mysql
$ yum list mysql*
$ yum info package1
$ yum list
$ yum list package1
$ yum groupinfo group1
# remove packages
$ yum remove package1
$ yum groupremove group1
$ yum deplist package1
# clean caches
$ yum clean packages
$ yum clean headers
$ yum clean oldheaders5. dnf
RHEL 8, CentOS 8
dnfis the next‑generation package manager that replaces yum; it uses libsolv for dependency resolution and is written in Python.
Installing DNF
# enable EPEL repository
$ yum install -y epel-release
# install DNF
$ yum install -y dnf
# verify installation
$ dnf --versionCommon DNF commands
# install a package
$ dnf install nano
# upgrade a package
$ dnf update systemd
# upgrade all packages
$ dnf update
$ dnf upgrade
# check for updates
$ dnf check-update
# remove a package
$ dnf remove nano
$ dnf erase nano
# clean unused packages and caches
$ dnf autoremove
$ dnf clean all
# list repositories
$ dnf repolist
$ dnf repolist all
# list all RPM packages
$ dnf list
$ dnf list installed
$ dnf list available
# search packages
$ dnf search nano
# find which package provides a file
$ dnf provides /bin/bash
# show package details
$ dnf info nano
# manage package groups
$ dnf grouplist
$ dnf groupinstall 'Educational Software'
$ dnf groupupdate 'Educational Software'
$ dnf groupremove 'Educational Software'
# reinstall a package
$ dnf reinstall nano
# downgrade a package
$ dnf downgrade acpid
# view command history
$ dnf history
# get help for a command
$ dnf help
$ dnf help cleanThese tools together cover the most widely used Linux package management workflows across both Debian‑based and Red Hat‑based ecosystems.
Signed-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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
