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.
dnf list command is used to list packages in Fedora and Red Hat-based systems.
dnf list [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.
You can expect a very long output as it contains all the packages - You may filter using specific package or by using options.
dnf list zipor
dnf list "*zip*"
List Installed Packages
To list only the installed packages use the installed option.
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
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
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
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
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>
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
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.
dnf repository-packages epel list installedor
dnf repository-packages fedora list available
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
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.
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