Bookmark this page

Guided Exercise: Install and Update Software Packages with DNF

Install and remove packages and package groups.

Outcomes

  • Install and remove packages with dependencies.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command ensures that all required resources are available.

[student@workstation ~]$ lab start software-dnf

Instructions

  1. From workstation, open an SSH session to the servera machine as the student user. Use the sudo -i command to switch to the root user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ sudo -i
    [sudo] password for student: student
    [root@servera ~]#
  2. Search for a specific package.

    1. Try to run the nmap command. You should find that it is not installed.

      [root@servera ~]# nmap
      -bash: nmap: command not found
    2. Use the dnf search command to search for packages with nmap as part of their name or summary.

      [root@servera ~]# dnf search nmap
      ...output omitted...
      ========================= Name Exactly Matched: nmap ==========================
      nmap.x86_64 : Network exploration tool and security scanner
      ======================== Name & Summary Matched: nmap =========================
      nmap-ncat.x86_64 : Nmap's Netcat replacement
    3. Use the dnf info command to obtain more information about the nmap package.

      [root@servera ~]# dnf info nmap
      ...output omitted...
      Available Packages
      Name         : nmap
      Epoch        : 3
      Version      : 7.91
      Release      : 10.el9
      ...output omitted...
  3. Use the dnf install command to install the nmap package.

    [root@servera ~]# dnf install nmap
    ...output omitted...
    Dependencies resolved.
    ===============================================================================
     Package
            Arch     Version            Repository                            Size
    ===============================================================================
    Installing:
     nmap   x86_64   3:7.91-10.el9      rhel-9.0-for-x86_64-appstream-rpms   5.6 M
    
    Transaction Summary
    ===============================================================================
    Install  1 Package
    
    Total download size: 5.6 M
    Installed size: 24 M
    Is this ok [y/N]: y
    ...output omitted...
    Complete!
  4. Remove packages.

    1. Use the dnf remove command to remove the nmap package, but respond with no when prompted. How many packages are removed?

      [root@servera ~]# dnf remove nmap
      Dependencies resolved.
      ===============================================================================
       Package
              Arch     Version           Repository                             Size
      ===============================================================================
      Removing:
       nmap   x86_64   3:7.91-10.el9     @rhel-9.0-for-x86_64-appstream-rpms    24 M
      
      Transaction Summary
      ===============================================================================
      Remove  1 Package
      
      Freed space: 24 M
      Is this ok [y/N]: n
      Operation aborted.
    2. Use the dnf remove command to remove the tar package, but respond with no when prompted. How many packages are removed?

      [root@servera ~]# dnf remove tar
      ...output omitted...
      Dependencies resolved.
      ===============================================================================
       Package        Arch   Version       Repository                           Size
      ===============================================================================
      Removing:
       tar            x86_64 2:1.34-3.el9  @System                             3.0 M
      Removing dependent packages:
       cockpit        x86_64 264-1.el9     @rhel-9.1-for-x86_64-baseos-rpms     57 k
       cockpit-system noarch 264-1.el9     @System                             3.3 M
      ...output omitted...
      
      Transaction Summary
      ===============================================================================
      Remove  12 Packages
      
      Freed space: 48 M
      Is this ok [y/N]: n
      Operation aborted.
  5. Gather information about the "Security Tools" component group and install it on servera.

    1. Use the dnf group list command to list all available component groups.

      [root@servera ~]# dnf group list
    2. Use the dnf group info command to obtain more information about the Security Tools component group, including a list of included packages.

      [root@servera ~]# dnf group info "Security Tools"
      ...output omitted...
      Group: Security Tools
       Description: Security tools for integrity and trust verification.
       Default Packages:
         scap-security-guide
       Optional Packages:
         aide
         hmaccalc
         openscap
         openscap-engine-sce
         openscap-utils
         scap-security-guide-doc
         scap-workbench
         tpm2-tools
         tss2
         udica
    3. Use the dnf group install command to install the Security Tools component group.

      [root@servera ~]# dnf group install "Security Tools"
      ...output omitted...
      Dependencies resolved.
      ===============================================================================
       Package         Arch   Version       Repository                          Size
      ===============================================================================
      Installing group/module packages:
       scap-security-guide
                       noarch 0.1.60-5.el9  rhel-9.0-for-x86_64-appstream-rpms 683 k
      Installing dependencies:
       openscap        x86_64 1:1.3.6-3.el9 rhel-9.0-for-x86_64-appstream-rpms 2.0 M
      ...output omitted...
      
      Transaction Summary
      ===============================================================================
      Install  5 Packages
      
      Total download size: 3.0 M
      Installed size: 94 M
      Is this ok [y/N]: y
      ...output omitted...
      Installed:
        openscap-1:1.3.6-3.el9.x86_64
        openscap-scanner-1:1.3.6-3.el9.x86_64
        scap-security-guide-0.1.60-5.el9.noarch
        xmlsec1-1.2.29-9.el9.x86_64
        xmlsec1-openssl-1.2.29-9.el9.x86_64
      
      Complete!
  6. Explore the history and undo options of the dnf command.

    1. Use the dnf history command to display recent dnf history.

      [root@servera ~]# dnf history
      ID     | Command line             | Date and time    | Action(s)      | Altered
      -------------------------------------------------------------------------------
           3 | group install Security T | 2022-03-24 15:23 | Install        |    6
           2 | install nmap             | 2022-03-24 15:12 | Install        |    1
           1 | -y install @base firewal | 2022-03-03 04:47 | Install        |  156 EE

      On your system, the history is probably different.

    2. Use the dnf history info command to confirm that the last transaction is the group installation. In the following command, replace the transaction ID with the one from the preceding step.

      [root@servera ~]# dnf history info 3
      Transaction ID : 3
      Begin time     : Thu 24 Mar 2022 03:23:56 PM EDT
      Begin rpmdb    : 7743aed72ac79f632442c9028aafd2499a1591f92a660b3f09219b422ca95f02
      End time       : Thu 24 Mar 2022 03:23:58 PM EDT (2 seconds)
      End rpmdb      : 20c4f0215388b7dca9a874260784b1e5cf9bc142da869967269e3d84dd0f789d
      User           : Student User <student>
      Return-Code    : Success
      Releasever     : 9
      Command Line   : group install Security Tools
      Comment        :
      Packages Altered:
          Install openscap-1:1.3.6-3.el9.x86_64           @rhel-9.0-for-x86_64-appstream-rpms
          Install openscap-scanner-1:1.3.6-3.el9.x86_64   @rhel-9.0-for-x86_64-appstream-rpms
      ...output omitted...
    3. Use the dnf history undo command to remove the set of packages that were installed when the nmap package was installed. On your system, find the correct transaction ID from the output of the dnf history command, and then use that ID in the following command.

      [root@servera ~]# dnf history undo 2
  7. Return to the workstation system as the student user.

    [root@servera ~]# exit
    logout
    [student@servera ~]$ exit
    Connection to servera closed.
    [student@workstation ~]$

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish software-dnf

Revision: rh199-9.3-8dd73db