Skip to main content

Command Palette

Search for a command to run...

Linux basics - Tutorial 4[redhat]

Updated
11 min readView as Markdown
Linux basics - Tutorial 4[redhat]
P
I am Instructional Designer with interest in Cloud Computing, Devops and Infrastructure management. I also write code to automate the boring stuff.

Redhat Linux Basics - Tutorial 4.

Package Management in Red Hat Linux (RHEL)

Package management is one of the most important responsibilities of a Linux System Administrator or DevOps Engineer.

Almost every software installation, update, bug fix, and security patch is performed through the package manager.

In Red Hat Enterprise Linux (RHEL), the default package manager is DNF (Dandified YUM).

Note: In RHEL 7, the package manager is YUM.
In RHEL 8 and RHEL 9, DNF replaces YUM (although the yum command still works as an alias).


Popular Linux Distributions and Their Package Managers

Different Linux distributions use different package managers and package formats.

Although Linux commands are largely the same across distributions, the way software is installed and managed varies depending on the distribution family.


Linux Distribution Families

Distribution Family Popular Distributions Package Manager Package Format
Red Hat Family RHEL, CentOS Stream, Rocky Linux, AlmaLinux, Fedora dnf / yum .rpm
Debian Family Debian, Ubuntu, Linux Mint, Pop!_OS apt .deb
SUSE Family openSUSE, SUSE Linux Enterprise (SLES) zypper .rpm
Arch Family Arch Linux, Manjaro, EndeavourOS pacman .pkg.tar.zst
Alpine Linux Alpine Linux apk .apk
Gentoo Linux Gentoo emerge Source Code
Slackware Slackware slackpkg .txz

Red Hat Family

  • Red Hat Enterprise Linux (RHEL)

  • Rocky Linux

  • AlmaLinux

  • CentOS Stream

  • Fedora

Package Manager

dnf

Older versions:

yum

Package Format

.rpm

Install Package

sudo dnf install git -y

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.16.11 AM Screenshot 2026-08-03 at 11.16.21 AM

Note: You can see that the software package git is installed and it shows complete.

What is a Package?

A package is a compressed file that contains:

  • Software

  • Libraries

  • Configuration files

  • Documentation

  • Dependencies

Examples:

  • httpd (Apache Web Server)

  • git

  • nano

  • docker

  • python3

Instead of downloading software manually, Linux installs packages using package managers.


What is DNF?

DNF (Dandified YUM) is the package manager used in Red Hat Enterprise Linux 8 and later.

It is responsible for:

  • Installing packages

  • Updating packages

  • Removing packages

  • Searching packages

  • Resolving dependencies

  • Managing repositories


Check DNF Version

dnf --version

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.21.54 AM

Explanation

  • dnf → Package manager

  • --version → Displays the installed DNF version


Check Installed Repositories

dnf repolist

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.25.31 AM

Explanation

Displays all enabled software repositories.


Display All Repositories

dnf repolist all

Shows both enabled and disabled repositories.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.26.44 AM

Search for a Package

dnf search git

Explanation

Searches for packages related to git online.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 5.56.09 PM


Display Package Information

dnf info git

If you type this in the terminal you get the output as shown below. Screenshot 2026-08-03 at 5.58.41 PM

Displays

  • Version

  • Repository

  • Description

  • Architecture

  • Size


Install a Package

sudo dnf install git -y

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.16.11 AM Screenshot 2026-08-03 at 11.16.21 AM

Explanation

  • sudo → Run with administrator privileges.

  • dnf → Package manager.

  • install → Installs a package.

  • git → Package name.

  • -y → Automatically answers "Yes."


Install Multiple Packages

sudo dnf install git nano wget curl -y

Installs multiple packages in one command.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.34.44 AM

Verify Package Installation

rpm -q git

or

git --version

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.35.57 AM

List Installed Packages

dnf list installed

Displays every installed package.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.38.43 AM

List a Specific Installed Package

dnf list installed git

Checks whether Git is installed.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.40.27 AM

Update a Single Package

sudo dnf update git -y

Updates only Git.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.43.57 AM

Update All Packages

sudo dnf update -y

Updates every installed package to the latest available version.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.41.54 AM Screenshot 2026-08-03 at 11.43.19 AM

Upgrade the Entire System

sudo dnf upgrade -y

Performs a complete system upgrade.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.45.11 AM

Remove a Package

sudo dnf remove nano -y

Uninstalls Nano.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.47.46 AM

Reinstall a Package

sudo dnf reinstall git -y

Reinstalls Git.

Useful when package files become corrupted.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.52.56 AM

Display Package Dependencies

dnf deplist git

Shows all package dependencies.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.55.32 AM

Install a Local RPM Package

sudo dnf install ./package.rpm

Installs an RPM file downloaded locally.


Install Using RPM

sudo rpm -ivh package.rpm

Explanation

  • -i → Install

  • -v → Verbose

  • -h → Progress bar

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.07.22 PM

Verify Installed RPM

rpm -q nano

Checks whether nano is installed.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.08.40 PM

Display Package Files

rpm -ql git

Lists every file installed by the package.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.58.20 AM

Display Package Information

rpm -qi git

Displays detailed package information.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 11.59.43 AM

Verify Package Integrity

rpm -V git

Checks whether installed package files have been modified.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.00.54 PM

Remove an RPM Package

sudo rpm -e package_name

Removes an RPM package.

Note: Remove any package on your own and observe the output.


Clean Cached Packages

sudo dnf clean all

Deletes cached packages and metadata.

Useful when troubleshooting repository issues.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.02.20 PM

Download Packages Without Installing

dnf download git

Downloads the RPM package without installing it.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.06.28 PM

Display Package History

dnf history

Displays installation, removal, and update history.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.11.57 PM

Undo a Package Installation

sudo dnf history undo 10

Reverts transaction number 10.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.16.56 PM

Check Available Updates

dnf check-update

Displays packages that can be updated.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.18.15 PM

Install Apache Web Server

sudo dnf install httpd -y

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.20.32 PM

Start Apache

sudo systemctl start httpd

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.22.24 PM

Enable Apache on Boot

sudo systemctl enable httpd

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.22.24 PM

Verify Apache Installation

systemctl status httpd

If you type this in the terminal you get the output as shown below.

Screenshot 2026-08-03 at 12.22.24 PM

Practical DevOps Lab - Practice task for you

Search for Git

dnf search git

View Git Information

dnf info git

Install Git

sudo dnf install git -y

Verify Installation

git --version

Install Nano

sudo dnf install nano -y

Install Apache

sudo dnf install httpd -y

Verify Apache Package

rpm -q httpd

List Files Installed by Apache

rpm -ql httpd

Remove Nano

sudo dnf remove nano -y

View Package History

dnf history

Clean DNF Cache

sudo dnf clean all

Commands Covered

Command Purpose
dnf --version Display DNF version
dnf repolist List enabled repositories
dnf repolist all List all repositories
dnf search Search packages
dnf info Display package information
dnf install Install packages
dnf remove Remove packages
dnf reinstall Reinstall packages
dnf update Update packages
dnf upgrade Upgrade the system
dnf list installed List installed packages
dnf check-update Check available updates
dnf history Display package transaction history
dnf history undo Roll back a transaction
dnf clean all Clear package cache
dnf module list Display software modules
rpm -q Check installed RPM
rpm -qi Display RPM information
rpm -ql List package files
rpm -V Verify package integrity
rpm -ivh Install RPM package
rpm -e Remove RPM package

Summary

In this tutorial, you learned:

  • What packages are in Linux

  • The difference between DNF, YUM, and RPM

  • How to search, install, update, and remove software

  • How to verify installed packages

  • How to manage repositories

  • How to work with RPM packages

  • How to roll back package transactions

  • How package management is used in real-world DevOps environments

Package management is one of the most frequently used skills in Linux administration and forms the foundation for installing web servers, databases, programming languages, monitoring tools, CI/CD software, and container platforms.

With this we come to the end of the tutorial 4 of Linux. Thank you for going through this. See you all in some other tutorial series.. Until then Happy Learning 😀