Linux Package Management: How to Use Apt and DNF

A collection of cardboard boxes

No matter which Linux distribution you're using, package management is critical for installing, updating, and removal of software applications. Almost every popular Linux distribution has its package management system and understanding its functioning is important to efficiently manage a Linux box on a day-to-day basis. In this tutorial, I've picked three popular package managers viz., Apt, Yum, and DNF, that are supported by some of the most popular Linux distributions. We'll take a look at some of the basic commands of these package managers to make you familiar with their features.

A collection of cardboard boxes

Although GUI versions of these package managers too exist within their respective distribution's desktop environment, mastering the command-line version of the same is advisable. It gives you more power.

Read Also:
Linux File System Demystified [Beginner's Guide]

Savvy users can skim their help docs to deep dive into advanced options and commands. Although, for most users, some of the basic commands are good enough for daily use. Let's get started!

What is Package Management?

Let's first understand what exactly package management is in this context.

A package management system is a collection of tools made for the end users to easily maintain, install, uninstall, update, and query software applications.

Such a package management system keeps track of all the installed software packages on a Linux system and tracks their dependencies. It makes sure that the installed packages are free from any anomaly and work seamlessly.

In simple words, a package management system keeps your Linux system free from clutter and keeps it in a healthy condition when dealing with the maintenance of software applications.

Apt: Package Management for Debian-based Systems

If you're using a Debian-based distribution like Ubuntu, the default package management system is Apt (Advanced Package Tool) which is also used in all the derivates of Debian-based distributions.

Let's explore some of its essential and basic commands to install, update, and remove software applications.

Install a Package

Here's a basic command to install packages from the apt command.

sudo apt install package_name

Here package_name is the name of the software application we're going to install from the official repository. Note the use of the sudo command to give you enough power or privilege to make system changes in your Linux installation.

And, in case you've downloaded the application package on your local filesystem, use the following command to install it.

sudo dpkg -i /path/to/package_file.deb

While installing a package from the local filesystem, it may happen that the dependencies of that package are not available locally. In such a case, you'll get dependency errors.

To resolve this issue, use the gdebi tool that automatically pulls dependencies from the official repositories while installing packages from the local file system.

Update Packages

And now, let's see how to update existing packages.

First of all, you need to update the packages list.

sudo apt update

And then, update the packages.

sudo apt upgrade

Depending on the number of packages installed on your system, it may take some time to complete the updation process.

Remove a Package

To remove a package from your Linux system, use this simple command.

sudo apt remove package_name

To remove more than one package, mention the package name in the command with whitespace in between. The sample principle applies when installing multiple packages in a single go.

DNF: Package Management for RPM-based Systems

If you're using Linux distributions like Red Hat EL 8+, Fedora 22+, or CentOS 8+, DNF (Dandified Yum) is the default package manager. It's the successor of the much popular YUM package manager.

Read Also:
How to Recover Deleted Files in Linux

Without wasting any time, let's see how to manage application software through this next-generation package manager.

Install a Package

To install a package through DNF, use the following command.

sudo dnf install package_name

Feel free to supply multiple package names separated by white space if you want to install several applications—in a single command.

Update Packages

To update packages, use the following two commands.

# Update packages list
dnf check-update

# Update packages/applications
sudo dnf upgrade

Make sure you use these commands in the same sequence as shown above.

Remove a Package

To remove a package through DNF, the following command can be used.

sudo dnf erase package_name

In this command too, you can specify multiple package names to kickstart the removal of several applications—in one go.


Package management systems are an efficient and reliable way to manage application software on Linux computers. They're easy to use and help you in installing, updating, and removing applications.

Both Apt and DNF are the most popular package management systems and are available as a default in their respective Linux distributions.

Mastering these package management systems is essential to harness the full power of your Linux box. Although GUI versions are also available, I'll strongly recommend getting familiar with the command-line versions of these package management tools.