How to manage packages on RPM-based Linux distributions with DNF

One of the most attractive features of the Linux operating system is its ease of installation or automation of the installation of software packages from secure remote repositories.

These instructions will walk you through installing and managing software packages on RPM-based Linux distributions such as Fedora and Red Hat Enterprise Linux (RHEL) with DNF, the next generation package manager for RPM-based Linux distributions.

What is DNF?

DNF is the successor program to YUM (Yellowdog Updater Modified) and is the standard package manager on Fedora and RHEL. The name DNF is short for Dandified YUM.

The main purpose of DNF is to make it easier to install, query, and manage software packages on servers and desktops. Like other mainstream package managers on Linux, DNF resolves all software package dependencies during installation.

DNF also maintains backward compatibility with YUM, so your older scripts will run without any problems. Indeed, if you have the yummy Command on new Linux distributions, it actually uses DNF in the background. You can check this by running the command:

                        ls -l /usr/bin/yum

As you can see in the output, the yummy Command is simply a symbolic link to dnf .

Find software packages with DNF

An important part of package management is querying or looking for packages that interest you both locally and in remote repositories. You can search for packages based on package name, package content or keywords, etc.

To the exampleIf you want to find some web browsers that you might be able to install, you can start a general search with the keyword “browser”.

                        dnf search browser

The output is a list of all software packages that contain the word “browser” in the package name or description.

If you want more information about a particular package, e.g. example, the Firefox Browser you can use the the information Subcommand as follows:

                        dnf info firefox

The output gives you more detailed information about the package, such as: B. Architecture, package size, version number, license, etc.

You can also list all of the packages available for installation from the configured repositories by using the perform Method. We have the fewer Command to list the packages one screen at a time.

                        dnf list available | less

Use the F. to scroll forward and the B. Scroll back button. You can also search the output for a keyword by pressing / and then entering your keyword. Press Q to leave the command output.

Use the following command to view all of the installed software packages on your PC:

                        dnf list installed

Install software packages

Installing packages with DNF is pretty straightforward. However, you need elevated rights as root or sudo User. To the exampleto install the Firefox Browser, just run the following command and then press AND at the command prompt that appears to agree to the terms:

                        sudo dnf install firefox

As mentioned earlier, the dnf command takes care of installing all of the dependencies for a package. To see all the dependencies that are part of the Firefox Installation, use the dissolve Subcommand followed by the package name.

                        dnf deplist firefox

Uninstalling software packages

Removing packages is an equally important exercise in managing software. One of the easiest ways to remove or uninstall a package is to use the Extinguish Method.

                        sudo dnf remove firefox

Another way to remove software packages is through the story Subcommand. DNF keeps a record of all transactions in which software packages are installed or removed. To view previous DNF transactions, you can run the following command:

                        dnf history

The output lists previous actions or transactions in tabular form. In this case the output shows that we previously installed vim and chromium.

With the story You can use subcommand to undo or remove all previous transactions. To the exampleto remove the vim package just run the story Command with the cancel followed by the transaction ID, and then press Y when prompted to continue.

                        sudo dnf history undo 3

As a best practice, you should get more details about a transaction before undoing it to avoid side effects. You can view the details of a transaction with the following command:

                        sudo dnf history info 3

Remember to replace 3 with the corresponding transaction ID that you are interested in.

Remove unused dependencies

One of the things that take up space on Linux PCs is packages and dependencies that are no longer needed by the system.

Run the following command to remove such dependencies:

                        sudo dnf autoremove

In addition, DNF can also be used to remove data that was downloaded along with installed packages.

                        sudo dnf clean packages

You can also clean up your software package cache and other metadata that is part of the installed packages by running the following command:

                        sudo dnf clean metadata

Reinstall software packages

From time to time you may only need to install certain components of a package. To the exampleif you accidentally download certain software packages from. Clear firefox , you can reinstall them by running:

                        sudo dnf reinstall firefox

Update packages with DNF

Keeping your software updated is one of the best ways to keep a robust and secure system as new software includes the latest security patches and bug fixes.

To get the latest software package updates from remote repositories, you can use the Check update Subcommand as follows:

                        sudo dnf check-update

After getting the updates, you can use them with. apply to all installed software packages To update .

                        sudo dnf update

The output shows the total number of packages DNF will update.

You can also update a specific package, e.g. example, firefox, with the following command:

                        sudo dnf update firefox

Alternative and modern package management

This guide has examined how software packages run on RPM-based Linux distributions such as: Fedora and Red Hat Enterprise Linux (RHEL) with the DNF command. You can also use YUM and RPM package managers on Fedora.

Another modern way to distribute software packages on Linux is Flatpak, a solution that allows you to build and distribute a package on multiple supported Linux distributions.

Related Posts