Bookmark this page

Installing Software Packages

Objectives

  • Use the command line to install packages from different sources.

Installing Software Packages

The GNOME Software desktop application is a front end to the DNF (formerly YUM) package management system. On the command line, the DNF system keeps track of what software is available from configured repositories, what software is installed on your system, and what upgrades are available. You can search for desktop applications and commands, and then install and upgrade them, by using the dnf command.

Listing Repositories

The availability of software applications is determined by the repositories that are configured on your system. On computers that are managed by a corporate IT department, the repositories are often configured for you. To see the repositories that are configured on your system, use the dnf repolist command.

[user@host ~]$ dnf repolist
repo id                                repo name
rhel-9.1-for-x86_64-appstream-rpms     Red{nbsp}Hat Enterprise Linux 9.1 AppStream
rhel-9.1-for-x86_64-baseos-rpms        Red{nbsp}Hat Enterprise Linux 9.1 BaseOS

Finding an Application on the Command Line

You can find applications by name, by a descriptive keyword, or by listing all applications that are available in the repository. To search for an application by name, use the dnf search command followed by the application name. For example, the following command searches for the zsh package, which contains the zsh shell:

[user@host ~]$ dnf search zsh
Last metadata expiration check: 0:01:20 ago on Thu Nov  9 16:15:06 2023.
==== Exactly Matched: zsh ====
zsh.x86_64 : Powerful interactive shell

If you do not have a particular application in mind, but you need an application that serves a specific purpose, then you can search by summary instead.

[user@host ~]$ dnf search shell
Last metadata expiration check: 0:01:20 ago on Thu Nov  9 16:16:16 2023.
...output omitted...
==== Summary Matched: shell ====
tcsh.x86_64 : An enhanced version of csh, the C shell
zenity.x86_64 : Display dialog boxes from shell scripts
zsh.x86_64 : Powerful interactive shell

Alternatively, you can list all applications in the configured repositories by using the dnf list all command.

[user@host ~]$ dnf list all
repo id                                repo name
rhel-9.1-for-x86_64-appstream-rpms     Red{nbsp}Hat Enterprise Linux 9.1 AppStream (dvd)
rhel-9.1-for-x86_64-baseos-rpms        Red{nbsp}Hat Enterprise Linux 9.1 BaseOS (dvd)
Last metadata expiration check: 0:17:56 ago on Thu Nov  9 16:15:06 2023.
Installed Packages
ModemManager.x86_64          1.18.2-3.el9      @rhel-9-for-x86_64-baseos-rpms
ModemManager-glib.x86_64     1.18.2-3.el9      @rhel-9-for-x86_64-baseos-rpms
NetworkManager.x86_64        1:1.40.0-1.el9    @System
NetworkManager-adsl.x86_64   1:1.40.0-1.el9    @rhel-9-for-x86_64-baseos-rpms
...output omitted...

Installing an Application on the Command Line

After you have found an application, you can install it by using the dnf install command followed by the name of the application. Packages that you install by using the dnf command are available to all users on the system. You must use sudo privileges to install packages because installing software is a system-wide change.

For example, the following command installs the zsh shell, which runs in the Terminal window:

[user@host ~]$ sudo dnf install zsh

You can install more than one application with a single command by providing more than one application name.

[user@host ~]$ sudo dnf install tcsh zsh

Setting up Flatpak

The dnf command requires administrative privileges. As an administrator, you might want to allow your users to install applications without providing them access to sudo privileges. Alternatively, you might be a user on a computer that is managed by a corporate IT department, and you might not have permission to install software outside of approved repositories. The Flatpak system uses Linux containers to safely install desktop applications without granting users administrative permissions.

Some applications are available through the dnf command and as a Flatpak, but only Flatpaks are available without the use of sudo privileges. The largest repository of Flatpaks is Flathub, an open source project that serves as a centralized location for software from many different developers.

To set up the Flatpak system, open a web browser and navigate to https://flathub.org and click Set Up Flathub. Scroll through the list of distributions, select the name of your Linux distribution, and follow the installation instructions. This course uses Red Hat Enterprise Linux.

In RHEL, Flatpak is available through DNF and it might already be installed. To install Flatpak, use the dnf install flatpak command with sudo privileges.

[user@host ~]$ sudo dnf install flatpak
...output omitted...
Is this ok [y/N]: y
Complete!

Flatpak uses repositories to search for and install packages. Many organizations publish a Flatpak repository to distribute their software. To add a Flatpak repository to the system, use the flatpak remote-add command. If the repository already exists and you try to add the repository, then the command fails. You can use the flatpak remote-add command with the --if-not-exists option to avoid the command failure if the repository already exists.

In this example, you add the Flathub repository by using the https://dl.flathub.org/repo/flathub.flatpakrepo URL.

[user@host ~]$ flatpak remote-add --if-not-exists \
flathub https://dl.flathub.org/repo/flathub.flatpakrepo

Verify that the Flathub repository is available in the local system by using the flatpak remotes command to list Flatpak repositories.

[user@host ~]$ flatpak remotes
Name    Options
flathub system

To verify that the setup commands were successful, and that you have added Flathub as a software repository, open the GNOME Software application. Click the application's menu in the upper right, and then select Software Repositories. The Software Repositories dialog lists Flathub as an available repository.

Figure 6.4: Flathub repository on GNOME Software

Some Flatpak repositories use an additional string at the beginning of the URL to refer to an Open Container Initiative (OCI) registry. For example, the Fedora Flatpak repository URL is oci+ https://registry.fedoraproject.org, which you can use as a regular URL.

[user@host ~]$ flatpak remote-add \
--if-not-exists fedora oci+https://registry.fedoraproject.org

Finding Desktop Applications with Flatpak

The GNOME Software application makes it convenient to browse Flatpak applications that are built for the desktop. Explore applications by category, or use the search function to locate applications by name or description.

Installing Desktop Applications with Flatpak

Before installing a Flatpak application, click the application name in GNOME Software. Read the description of the application carefully. Each application's description explains the size of the installation, whether the application has access to your personal data or to the network, what organization supports it, and more. The source repository that provides the application is listed in the upper right corner of GNOME Software.

Figure 6.5: A Flatpak application on GNOME Software

To install an application as a Flatpak, click Install.

After the installation is complete, click Open to launch it. Alternatively, you can launch the application from the Activities Overview.

References

dnf(8) and flatpak(1) man pages

For more information, refer to How to Install Software Packages on Red Hat Enterprise Linux (RHEL) at https://learn.spidernet.pl/sysadmin/install-software-packages-rhel

For more information about installing applications with Flatpaks, refer to Install Apps on Linux with Flatpak at https://opensource.com/article/21/11/install-flatpak-linux

Revision: rh104-9.1-3d1f2bc