How to List Installed Packages using DNF

Written by: Bobbin Zachariah   |   Last updated: January 31, 2023

Listing installed packages help to keep track of installed packages, troubleshooting package conflicts, and disk space management. There are several package managers that can be used to list installed packages in Linux, including DNF. DNF is a more user-friendly packager manager specific for Fedora and Red Hat-based Linux Distributions.

In this tutorial, we learn how to list installed Packages using DNF.

Listing Packages

dnf list command is used to list packages in Fedora and Red Hat-based systems.

Syntax:

dnf list [options]

Options:

  • installed - Lists all installed packages.
  • available - Lists all available packages that can be installed.
  • default - List all installed and available packages.

List all packages - installed and available

By default, dnf list command provides a list of all installed and available (in RPMDB and repository) packages.

Example:

dnf list 
output of dnf list

You can expect a very long output as it contains all the packages - You may filter using specific package or by using options.

Example:

dnf list zip
or
dnf list "*zip*"

List Installed Packages

To list only the installed packages use the installed option.

dnf list installed
dnf list installed

This command would output installed packages with their version.

You can further filter for a specific package using the grep command as follows:

dnf list installed | grep <package-name>

For example, to check python is installed, type:

dnf list installed | grep python
filter specific package from dnf list

The output above shows a list of all the python packages installed in the system.

List Extra Packages

Some packages are not a part of any configured repository. We term these packages as extra packages. To view the list of such packages, run the following command:

dnf list --extras 
dnf list extras

Since we don't have any extra packages, therefore none of the packages is listed in the output.

List Obsolete Packages

Your system might have some packages installed that are now obsolete. To view such packages, we can use the following command:

dnf list --obsoletes
dnf list obsolete packages

List Package Upgrades

Some packages require upgrades. You can use the following command dnf command to list all the packages that have an upgrade available:

dnf list --upgrades 
list package available for upgrade

The output displays the packages list with the title "Available Upgrades". Let's understand the output by explaining the first green line.

  • ModemManager - the name of the package,
  • x86_64 - CPU architecture of the upgrade package,
  • 1.18.12 - upgrade version available,
  • 1.fc37 - release of the upgrade version,
  • updates - the repository location of the updated package.

You can update any specific package using the following command:

dnf upgrade <package-name>
dnf upgrade a package

List Manually Installed Packages

You may have installed some packages manually (may be installed as dependencies) without using the dnf package manager. You can list these packages using the following command:

dnf history userinstalled
manually installed packages

The output above shows the list of all the packages manually installed by the user.

List Packages from Specific Repositories

We can use dnf to list the packages of a particular repository. For this purpose, you can use the repository-packages option with the dnf command.

dnf repository-packages <repo-name> list available/installed

This will list all the packages that are part of the repositories specified as <repo-name>. The option "installed" and "available" decides if to display only installed or all available packages.

Example:

dnf repository-packages epel list installed
or
dnf repository-packages fedora list available
list package from specific repository

The above output displays a list of all the available packages from the fedora repository.

4. List Installed Package with Size

If you want to get the size information of a specific package, use the "info" option with the dnf command.

dnf info <package-name>

Remember to replace <package-name> with the package name you want to get the size and other information. For example, the following image shows information (including the size details) for the samba package.

dnf info samba
list installed package size

Alternatively, when you install a particular package, it shows a prompt to the user for confirmation to install the package.

If you want to see the size of the package before installing it, you can use the following command:

dnf install <package-name> | grep "Installed-size" 

This will give you the installed size of the package before starting the installation.

Conclusion

In this tutorial, we learned how to list installed packages using DNF package manager.

Thanks for reading, please leave your feedback and suggestions in the below comment section.

Related Read: The DNF Command Handbook

About The Author

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is an experienced Linux engineer who has been supporting infrastructure for many companies. He specializes in Shell scripting, AWS Cloud, JavaScript, and Nodejs. He has qualified Master’s degree in computer science. He holds Red Hat Certified Engineer (RHCE) certification and RedHat Enable Sysadmin.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment