# Linux basics - Tutorial 4[redhat]

## 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

### Popular Distributions

*   Red Hat Enterprise Linux (RHEL)
    
*   Rocky Linux
    
*   AlmaLinux
    
*   CentOS Stream
    
*   Fedora
    

### Package Manager

```bash
dnf
```

Older versions:

```bash
yum
```

### Package Format

```text
.rpm
```

### Install Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/30a3e5b1-0f41-413e-adb2-6f3e6d8ff15d.png align="center")

![Screenshot 2026-08-03 at 11.16.21 AM](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/b29b4e48-3110-4f44-a8e6-6562e5977190.png align="center")

**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

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/1969fbba-82e0-4d47-959f-5f0d92c6f3aa.png align="center")

### Explanation

*   `dnf` → Package manager
    
*   `--version` → Displays the installed DNF version
    

* * *

# Check Installed Repositories

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/be25d34d-96b7-403f-bf43-a846c0d335d2.png align="center")

### Explanation

Displays all enabled software repositories.

* * *

# Display All Repositories

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/9853918a-d8a5-4eb2-b1ff-80b80dae58ad.png align="center")

* * *

# Search for a Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/adb1b0eb-1cfe-43fa-9056-51970df15659.png)

* * *

# Display Package Information

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/d489438b-9f56-447c-8349-ef4afd64440b.png)

Displays

*   Version
    
*   Repository
    
*   Description
    
*   Architecture
    
*   Size
    

* * *

# Install a Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/30a3e5b1-0f41-413e-adb2-6f3e6d8ff15d.png align="center")

![Screenshot 2026-08-03 at 11.16.21 AM](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/b29b4e48-3110-4f44-a8e6-6562e5977190.png align="center")

### Explanation

*   `sudo` → Run with administrator privileges.
    
*   `dnf` → Package manager.
    
*   `install` → Installs a package.
    
*   `git` → Package name.
    
*   `-y` → Automatically answers "Yes."
    

* * *

# Install Multiple Packages

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/fc4aae04-d8d0-4434-8a71-07fae8ebf8f4.png align="center")

* * *

# Verify Package Installation

```bash
rpm -q git
```

or

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/f5de656a-d52b-44d9-8494-87d45f51b409.png align="center")

* * *

# List Installed Packages

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/724034a8-d179-4b84-b5c5-06c61b8aa079.png align="center")

* * *

# List a Specific Installed Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/dbe5e469-00a2-4550-9edb-03bc1e5df1e3.png align="center")

* * *

# Update a Single Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/afd8691e-606e-4e10-8bc1-99b9696a8e47.png align="center")

* * *

# Update All Packages

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/e1bc3e57-f6ef-48ba-b2c5-7801fbf3e521.png align="center")

![Screenshot 2026-08-03 at 11.43.19 AM](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/dcb15682-9a68-416c-86b9-ebdc40ffa812.png align="center")

* * *

# Upgrade the Entire System

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/a0d39582-9c60-4b53-816c-a0665b4147eb.png align="center")

* * *

# Remove a Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/ac4ae30a-80e2-4ccc-b1c1-80b012bfd6a9.png align="center")

* * *

# Reinstall a Package

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/e4ba4f5b-7a75-4723-89c7-bdc08f16b607.png align="center")

* * *

# Display Package Dependencies

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/7cd9b1ce-a65a-41c1-9798-8a215971fcb9.png align="center")

* * *

# Install a Local RPM Package

```bash
sudo dnf install ./package.rpm
```

Installs an RPM file downloaded locally.

* * *

# Install Using RPM

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/52c9e5c4-79fd-4a9d-989f-5eab179f6c1f.png align="center")

* * *

# Verify Installed RPM

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/af68fd3c-f7af-4e70-8061-a735f1657513.png align="center")

* * *

# Display Package Files

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/102859a9-d7a3-4edb-a233-01709765ea48.png align="center")

* * *

# Display Package Information

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/3cee4867-8537-4535-a23a-b9bc66caecf0.png align="center")

* * *

# Verify Package Integrity

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/1e2f4bc6-274e-4c56-94dd-b173426ea7c0.png align="center")

* * *

# Remove an RPM Package

```bash
sudo rpm -e package_name
```

Removes an RPM package.

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

* * *

# Clean Cached Packages

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/533e4de4-5dc9-496c-8bef-dfa6af3c222f.png align="center")

* * *

# Download Packages Without Installing

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/e1b5b591-9348-4e40-b92b-c24784f1d734.png align="center")

* * *

# Display Package History

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/063eecfe-5b1b-4147-8a1e-96910d307c51.png align="center")

* * *

# Undo a Package Installation

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/baaa4a2e-d0ff-40b4-9d5f-e0be7db1a3ba.png align="center")

* * *

# Check Available Updates

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/9814a6f8-3258-4e14-9fb7-6b1a05c7df69.png align="center")

* * *

# Install Apache Web Server

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/a124e300-620e-4f12-9192-d869b9a6b753.png align="center")

# Start Apache

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/39f75f6d-c1b8-4329-98be-8e0b813ba222.png align="center")

# Enable Apache on Boot

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/3914adf4-8918-4241-9478-93b06e6d90e5.png align="center")

# Verify Apache Installation

```bash
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](https://cdn.hashnode.com/uploads/covers/62db945e38759e6b49829749/c8ae12a9-87be-41f6-8017-950940923d93.png align="center")

# Practical DevOps Lab - Practice task for you

## Search for Git

```bash
dnf search git
```

* * *

## View Git Information

```bash
dnf info git
```

* * *

## Install Git

```bash
sudo dnf install git -y
```

* * *

## Verify Installation

```bash
git --version
```

* * *

## Install Nano

```bash
sudo dnf install nano -y
```

* * *

## Install Apache

```bash
sudo dnf install httpd -y
```

* * *

## Verify Apache Package

```bash
rpm -q httpd
```

* * *

## List Files Installed by Apache

```bash
rpm -ql httpd
```

* * *

## Remove Nano

```bash
sudo dnf remove nano -y
```

* * *

## View Package History

```bash
dnf history
```

* * *

## Clean DNF Cache

```bash
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 😀**
