Listing Installed Packages With DNF

By | 2019-10-21

Listing installed packages with dnf is straightforward. Unlike rpm, dnf also shows you the repository packages were installed from. The following example demonstrates listing all packages installed on a system.

# dnf list installed
Installed Packages
acl.x86_64                           2.2.53-1.el8                          @anaconda  
audit.x86_64                         3.0-0.10.20180831git0047a6c.el8       @anaconda  
audit-libs.x86_64                    3.0-0.10.20180831git0047a6c.el8       @anaconda

The left column displays the name of the package along with its instruction set architecture. Packages with an architecture of noarch are architecture independent. They provide data files and programs written in interpreted languages such as python. The center column provides the version of the package. The right column displays the repository the package was installed from.

Using rpm

Installed packages can also be listed using rpm:

# rpm -qa
kernel-modules-4.18.0-80.el8.x86_64
tzdata-2019a-1.el8.noarch
python3-dateutil-2.6.1-6.el8.noarch

Unlike dnf, rpm displays the package name, version, and architecture concatenated together. In fact, if you were to add .rpm to the end of each line, you would have the file name of the packages as they are in the repository.

Filtering Output

Most systems have at least a few hundred packages installed. If you want to see if a particular package is installed, you can filter the output using globs.

Covering globs entirely would require a separate guide, so I’ll cover a few basics that should be enough for most situations. The * and ? characters are wildcards. The former expanding to anything or nothing, and the latter any single character. A few examples should clarify this.

Suppose you want to see all packages that start with x. The following command will do just that.

# dnf list installed "x*"
Installed Packages
xfsprogs.x86_64                         4.19.0-2.el8                  @anaconda 
xkeyboard-config.noarch                 2.24-3.el8                    @AppStream
xz.x86_64                               5.2.4-3.el8                   @anaconda 
xz-libs.x86_64                          5.2.4-3.el8                   @anaconda

Notice how I surrounded the glob with . If you forget to do this, your shell will interpret the wildcard character instead of dnf. It will try to match file names against the glob.

# ls
x_example
# dnf list installed x*
Error: No matching Packages to list
# dnf list installed "x*"
Installed Packages
xfsprogs.x86_64                         4.19.0-2.el8                  @anaconda 
xkeyboard-config.noarch                 2.24-3.el8                    @AppStream
xz.x86_64                               5.2.4-3.el8                   @anaconda 
xz-libs.x86_64                          5.2.4-3.el8                   @anaconda

Finally, ? matches any single character.

# dnf list installed "t?r"
Installed Packages
tar.x86_64                              2:1.30-4.el8                  @BaseOS

References