ITNuvoAkademiya
Academy homePackagesPlaylistsToolsSubnet calculatorSearchGlossary
CiscoCCNA · CCNA: networking fundamentals1. Introduction2. Network Fundamentals3. Network Access4. IP Connectivity5. IP Services6. IPv67. Security Fundamentals8. AutomationCCNP: Enterprise networks · coming soon
LinuxLinux: system administrator üçün · Linux for system administrators1. Getting to know Linux2. Working with text3. Users and permissions4. Processes and packages5. Inside the system6. Monitoring and logs7. NetworkingRed Hat Enterprise Linux · Red Hat Enterprise Linux: from beginner to advanced1. Getting started2. Packages3. Users and permissions4. SELinux5. Services6. Storage7. Networking8. Building services9. Boot and recovery10. DevOps11. Security and monitoring
FortinetFortiGate Administrator · FortiGate Administrator: from first login to ZTNA1. Getting to know FortiGate2. Routing, policy and NAT3. Security profiles4. Users and logs5. Resilience, SD-WAN and automation6. VDOM7. VPN and ZTNA8. Proxy9. DMZ
MonitoringZabbix · Zabbix: from installation to alerts1. Introduction2. Installation and the database3. Basics: groups, templates, users4. Connecting devices5. Alerts, Grafana and the API
VirtualizationProxmox VE · coming soonVMware ESXi · coming soon
My account / Sign in
AZENRU
← itnuvo.com

dnf: install, remove, search, history

Lesson 2.18 minBeginnerDecember 1, 2026
Open

This lesson is open to everyone. The other lessons open with a package: sign in or sign up, then choose a package.

Key points

  • dnf install, dnf remove, dnf upgrade — there is no separate step like apt update, dnf refreshes the list itself.
  • dnf search name, dnf info package, dnf provides */command — finding which package you need.
  • dnf group list / dnf group install "Development Tools" — a set of packages with one command.
  • dnf history keeps every transaction with a number, dnf history undo N rolls it back.
  • An installed service does not start on RHEL: systemctl enable --now is a separate step.

Compared with apt

JobUbuntu (apt)RHEL (dnf)
Refresh the listapt updateNot needed (automatic when the cache expires)
Installapt install nginxdnf install nginx
Removeapt remove nginxdnf remove nginx
Update everythingapt upgradednf upgrade
Searchapt searchdnf search
Detailsapt showdnf info
Which package owns a filedpkg -Sdnf provides / rpm -qf
History and undoNonednf history, dnf history undo

The yum command still works on RHEL 9, but it is really a redirect to dnf.

Installing and removing

srv-web01
[ali@srv-web01 ~]$ sudo dnf install -y httpd
Updating Subscription Management repositories.
Last metadata expiration check: 0:12:41 ago on Tue 01 Dec 2026 10:20:11 AM +04.
Dependencies resolved.
================================================================================
 Package               Arch     Version              Repository            Size
================================================================================
Installing:
 httpd                 x86_64   2.4.57-11.el9_4      rhel-9-appstream      47 k
Installing dependencies:
 apr                   x86_64   1.7.0-12.el9_3       rhel-9-appstream     126 k
 httpd-core            x86_64   2.4.57-11.el9_4      rhel-9-appstream     1.5 M
...
Complete!
[ali@srv-web01 ~]$ rpm -q httpd
httpd-2.4.57-11.el9_4.x86_64
[ali@srv-web01 ~]$ systemctl is-active httpd
inactive

Note the last line: the package is installed, but the service is not running. On RHEL the admin does this explicitly:

srv-web01
[ali@srv-web01 ~]$ sudo systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
CommandWhat it does
dnf install packageInstalls (-y — without asking)
dnf reinstall packageRestores damaged files
dnf remove packageRemoves (together with dependencies no longer needed)
dnf upgradeUpdates the whole system
dnf upgrade packageOnly one package
dnf check-updateAre there updates — without installing anything
dnf upgrade --securitySecurity updates only

Searching: which package do you need

srv-web01
[ali@srv-web01 ~]$ dnf search mariadb | head -n 4
======================== Name Exactly Matched: mariadb ========================
mariadb.x86_64 : A very fast and robust SQL database server
======================== Name & Summary Matched: mariadb ======================
mariadb-server.x86_64 : The MariaDB server and related files
[ali@srv-web01 ~]$ dnf provides "*/semanage"
policycoreutils-python-utils-3.6-2.1.el9.noarch : SELinux policy core python utilities
Repo        : rhel-9-for-x86_64-baseos-rpms
Matched from:
Filename    : /usr/sbin/semanage

dnf provides is very useful in RHCSA: when a command is missing (command not found), it finds which package provides it. For example, the semanage command is in the policycoreutils-python-utils package — hard to guess from the name.

Package groups

srv-web01
[ali@srv-web01 ~]$ dnf group list --hidden | head -n 6
Available Environment Groups:
   Server with GUI
   Server
   Minimal Install
Available Groups:
   Container Management
   Development Tools
[ali@srv-web01 ~]$ sudo dnf group install -y "Development Tools"

A group is a set of packages for one purpose: "Development Tools" brings gcc, make, git and so on.

History and undo

One of dnf's most useful features:

srv-web01
[ali@srv-web01 ~]$ sudo dnf history
ID     | Command line              | Date and time    | Action(s)      | Altered
--------------------------------------------------------------------------------
     4 | install -y php            | 2026-12-01 10:41 | Install        |   14
     3 | install -y httpd          | 2026-12-01 10:33 | Install        |    9
     2 | upgrade -y                | 2026-12-01 09:58 | Upgrade        |   37
     1 |                           | 2026-11-28 14:02 | Install        |  412 EE
[ali@srv-web01 ~]$ sudo dnf history info 4 | head -n 8
[ali@srv-web01 ~]$ sudo dnf history undo 4 -y

undo 4 fully rolls back transaction 4: it removes the 14 packages that came with php. If you installed the wrong package or an update caused trouble, this is the fastest way out.

The cache

srv-web01
[ali@srv-web01 ~]$ sudo dnf clean all
[ali@srv-web01 ~]$ sudo dnf makecache

When a repository changes or "metadata" errors appear, cleaning and rebuilding the cache helps.

Lab: install httpd and roll back

Start with the "dnf: install httpd" task in the Red Hat simulator, then try the history part on your own VM:

  1. Look at the repositories and install httpd:
srv-web01
[ali@srv-web01 ~]$ dnf repolist
[ali@srv-web01 ~]$ sudo dnf install -y httpd
[ali@srv-web01 ~]$ rpm -q httpd
  1. See that the service is not running, then start it:
srv-web01
[ali@srv-web01 ~]$ systemctl is-active httpd
inactive
[ali@srv-web01 ~]$ sudo systemctl enable --now httpd
[ali@srv-web01 ~]$ curl -s http://localhost | grep -o "<title>.*</title>"
<title>Test Page for the HTTP Server on Red Hat Enterprise Linux</title>
  1. (On your own VM) install the tree package, find the transaction number with dnf history and roll it back with dnf history undo. rpm -q tree → package tree is not installed.

Check: in the simulator "dnf: install httpd" is green, and curl localhost returns the test page.

Check yourself

5 questions · answers are shown instantly · 3 correct answers complete the lesson

1What is the RHEL equivalent of Ubuntu's apt update?

dnf refreshes the list automatically when the cache expires.

2semanage: command not found. How do you find which package you need?

provides searches by file name.

3How do you roll back a wrongly installed package together with its transaction?

history keeps every transaction with a number.

4Right after installing httpd, what does systemctl is-active httpd show?

On RHEL a service is started explicitly.

5Which command installs security updates only?

RHEL classifies updates (security, bugfix, enhancement).
Was this lesson useful?

Comments

Sign in to comment.