Linux 114: Package Management with APT, YUM, and DNF

Linux 114: Package Management with APT, YUM, and DNF

One of the core strengths of Linux is its powerful package management systems. Whether you're using a Debian-based system or a Red Hat-based system, understanding how to install, update, and manage packages is essential for system administration. In this article, we’ll explore the most commonly used package managers: APT, YUM, and DNF.


1. What is a Package Manager?

A package manager automates the process of:

  • Installing software
  • Updating software
  • Resolving dependencies
  • Removing unneeded packages

Each Linux distribution typically uses a different tool:

  • APT: Debian, Ubuntu
  • YUM: CentOS 6/7, RHEL 6/7
  • DNF: Fedora, CentOS 8+, RHEL 8+


2. Working with APT (Debian, Ubuntu)

Update Package Lists

sudo apt update


Upgrade All Installed Packages

sudo apt upgrade


Install a Package

sudo apt install nginx


Remove a Package

sudo apt remove nginx


Remove a Package and Its Configuration Files

sudo apt purge nginx


Search for a Package

apt search htop


Show Package Details

apt show htop


Clean Up Unused Packages

sudo apt autoremove sudo apt clean

3. Working with YUM (CentOS 6/7, RHEL 6/7)

YUM is deprecated in newer versions, but still widely used in legacy systems.

Update All Packages


sudo yum update

Install a Package


sudo yum install httpd

Remove a Package


sudo yum remove httpd

Search for a Package


yum search nano

Get Info About a Package


yum info nano

List All Installed Packages


yum list installed

Clean the Cache


sudo yum clean all

4. Working with DNF (Fedora, CentOS 8+, RHEL 8+)

DNF is the modern replacement for YUM, offering better performance, dependency resolution, and features.

Update Package Lists and Upgrade


sudo dnf upgrade

Install a Package


sudo dnf install nginx

Remove a Package


sudo dnf remove nginx

Search for a Package


dnf search git

Show Package Info


dnf info git

List Installed Packages


dnf list installed

Clean Package Cache


sudo dnf clean all

5. Repositories and Third-Party Software

Each package manager uses repositories (repos) to find and install packages.

  • APT Sources: /etc/apt/sources.list and /etc/apt/sources.list.d/
  • YUM/DNF Repos: /etc/yum.repos.d/*.repo

Add a third-party repo (APT example):


sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update

Add a DNF repo:


sudo dnf config-manager --add-repo=https://download.example.com/repo.repo

6. Handling Dependencies and Conflicts

APT, YUM, and DNF automatically resolve dependencies. If you encounter conflicts:

  • Use apt-get -f install to fix broken dependencies (APT).
  • Use dnf repoquery --requires <pkg> to inspect dependencies (DNF).
  • Use yum deplist <pkg> for detailed dependencies (YUM).


7. Best Practices

  • Always update package lists before installing.
  • Avoid forcing installations unless you understand the consequences.
  • Clean up unused packages and cache regularly.
  • Use official or trusted third-party repositories only.


8. Conclusion

Mastering your package manager is essential for system stability and efficiency. Whether you're managing a Debian-based or Red Hat-based system, APT, YUM, and DNF give you powerful tools to control your software environment.


Next Steps:

  • Learn about Snap and Flatpak for universal Linux package formats.
  • Explore unattended upgrades for automatic security updates.
  • Dive into building your own .deb or .rpm packages.


Stay tuned for the next article in the series:
Linux 115: Setting Up a Web Server with Apache or Nginx

Post a Comment (0)
Previous Post Next Post

ads