DEV Community

Sreekanth Kuruba
Sreekanth Kuruba

Posted on

Linux Package Management Explained Simply (apt, dnf, yum & rpm)

Quick Note

In my previous article, I mentioned that Linux Troubleshooting Flow for Beginners would be the final post in this series.

While preparing it, I realized there were a few practical Linux skills every beginner should learn first. These topics will make the troubleshooting guide much easier to understand and follow.

Before we wrap up the series, we'll cover:

Package Management
Finding Files & Text
Viewing Files Efficiently
File Compression

Then we'll bring everything together in the final Linux Troubleshooting Flow for Beginners.


Introduction

Installing software on Linux is very different from Windows.

On Windows, you usually download an .exe installer.

On Linux, software is typically installed and managed using package managers.

This is one of the most practical skills every Linux beginner should learn early.


What is a Package?

A package is a ready-to-install bundle that contains:

  • The main program
  • Required libraries
  • Configuration files
  • Documentation

Examples: nginx, git, docker, curl, vim

Think of a package as a ready-to-install software box.


What is a Package Manager?

A package manager is a tool that installs, updates, removes, and manages software packages.
Instead of downloading software manually, you simply run a command.

Example:

sudo apt install git

The package manager automatically:

  • Downloads packages from trusted repositories
  • Install required dependencies automatically
  • Upgrade installed software
  • Removes them cleanly

Instead of manual downloading, you just run one command.


Why Use a Package Manager?

Without package managers, you would have to:

Search for software manually
Download files from websites
Install dependencies yourself
Update each application separately

Package managers automate all of this.


What is a Repository?

Package managers download software from repositories.

A repository is a trusted online collection of software packages maintained by your Linux distribution.

Instead of downloading software from random websites, Linux installs it securely from these repositories.


Common Package Managers

Distribution Package Manager Low-level Tool
Ubuntu / Debian apt dpkg
Fedora / RHEL / Rocky dnf rpm
Older RHEL / CentOS yum rpm

Most Ubuntu users will use apt, while Fedora and modern RHEL-based systems use dnf.


Most Useful Commands

1. Update Package List

Before installing software, update the package list.

sudo apt update          # Ubuntu/Debian
sudo dnf check-update    # Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Note: apt update does not upgrade installed packages.


2. Upgrade Installed Packages

sudo apt upgrade   #Ubuntu/Debian
sudo dnf upgrade   #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Installs the latest available versions of your installed packages.


3. Install a Package

sudo apt install nginx   #Ubuntu/Debian
sudo dnf install nginx   #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Example packages:

sudo apt install git
sudo apt install curl
sudo apt install vim


4. Remove a Package

sudo apt remove nginx    #Ubuntu/Debian
# Remove package and configuration files
sudo apt purge nginx     
sudo dnf remove nginx    #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

5. Search for Packages

apt search docker    #Ubuntu/Debian
dnf search docker    #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Useful when you're unsure of the exact package name.


6. View Package Information

apt show nginx    #Ubuntu/Debian
dnf info nginx    #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Shows details such as:

Version
Description
Dependencies
Package size


7. List Installed Packages

apt list --installed   #Ubuntu/Debian
dnf list installed     #Fedora/RHEL
Enter fullscreen mode Exit fullscreen mode

Useful for verifying whether software is already installed.


Low-Level Tool: rpm

The rpm command works directly with RPM package files.

rpm -q nginx          # Check if installed
rpm -qi nginx         # Detailed info
Enter fullscreen mode Exit fullscreen mode

Usually you don't need to use rpm directly. On RPM-based systems, dnf handles package installation and dependencies for you.


Common Beginner Mistakes

  • Running apt upgrade without apt update first
  • Confusing apt update with apt upgrade
  • Installing software from random websites instead of official repositories
  • Forgetting to use sudo
  • Removing important system packages

Simple Mental Model

Think of a package manager like an App Store for Linux:

  • Package = App
  • Repository = App Store
  • Package Manager = Installer + Updater

Summary

In this guide you learned:

  • What packages and package managers are
  • Basic package management commands using apt and dnf
  • Basic package management commands
  • Common mistakes to avoid

Why This Matters

Package management is a daily task for:

Linux administrators
DevOps engineers
Cloud engineers
Developers

If you know how to manage packages, setting up and maintaining Linux systems becomes much easier.


Next Post:

Finding Files & Text in Linux Explained Simply (find, grep, which & whereis)


Top comments (0)