Bookmark this page

Guided Exercise: Installing Software Packages

Install software packages.

Outcomes

  • Search for and retrieve information about software packages.

  • Install software packages by using the command line.

  • Review package installation history.

As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.

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

Instructions

  1. Navigate to the Code directory. Try to run the make command.

    The make command compiles code and builds an executable file.

    1. Navigate to the Code directory.

      [student@workstation ~]$ cd Code
    2. Try to run the make command.

      [student@workstation Code]$ make
      bash: make: command not found...
      Failed to search for file: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Could not activate remote peer.

      The shell returns an error because it cannot find the make command.

  2. Search for and review information about the make package.

    1. Search for the make package by using the dnf command.

      [student@workstation Code]$ dnf search make
      Red Hat Enterprise Linux 9.1 BaseOS (dvd)         12 MB/s | 1.7 MB     00:00
      Red Hat Enterprise Linux 9.1 AppStream (dvd)      31 MB/s | 6.1 MB     00:00
      ====================== Name Exactly Matched: make ============================
      make.x86_64 : A GNU tool which simplifies the build process for users
      ...output omitted...

      The search results include packages that contain the string make in the package name and the summary.

    2. Obtain information about the make package.

      [student@workstation Code]$ dnf info make
      Last metadata expiration check: 0:08:51 ago on Tue Nov 21 23:49:09 2023.
      Available Packages
      Name         : make
      Epoch        : 1
      Version      : 4.3
      Release      : 7.el9
      Architecture : x86_64
      Size         : 542 k
      Source       : make-4.3-7.el9.src.rpm
      Repository   : rhel-9.1-for-x86_64-baseos-rpms
      Summary      : A GNU tool which simplifies the build process for users
      URL          : http://www.gnu.org/software/make/
      License      : GPLv3+
      Description  : A GNU tool for controlling the generation of executables and other
                   : non-source files of a program from the program's source files.
      ...output omitted...
  3. Install the make package and try to run the make command.

    1. Install the make package. Use sudo privilege for the student user to perform the installation.

      Use student as the password.

      Press y to confirm the installation.

      [student@workstation Code]$ sudo dnf install make
      [sudo] password for student: student
      Last metadata expiration check: 0:16:59 ago on Tue Nov 21 23:43:13 2023.
      Dependencies resolved.
      ==================================================================================
       Package   Architecture  Version         Repository                          Size
      ==================================================================================
      Installing:
       make      x86_64        1:4.3-7.el9     rhel-9.1-for-x86_64-baseos-rpms     542 k
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
    2. Verify that the make package is installed on your system.

      [student@workstation Code]$ dnf list installed make
      Installed Packages
      make.x86_64              1:4.3-7.el9           @rhel-9.1-for-x86_64-baseos-rpms
    3. Try to run the make command.

      [student@workstation Code]$ make
      gcc -c code.c -o code.o
      make: gcc: No such file or directory
      make: * [Makefile:4: code.o] Error 127

      The command returns an error because the compiler cannot find the gcc library.

  4. Search for and install the gcc package.

    1. Search for the gcc package by using the dnf command.

      [student@workstation Code]$ dnf search gcc
      Red Hat Enterprise Linux 9.1 BaseOS (dvd)              27 MB/s | 1.7 MB     00:00
      Red Hat Enterprise Linux 9.1 AppStream (dvd)           43 MB/s | 6.1 MB     00:00
      ========================== Name Exactly Matched: gcc ============================
      gcc.x86_64 : Various compilers (C, C++, Objective-C, ...)
      ========================= Name & Summary Matched: gcc ===========================
      gcc-c++.x86_64 : C++ support for GCC
      ...output omitted...

      The search results include packages that contain the string gcc in the package name and the summary.

    2. Obtain information about the gcc package.

      [student@workstation Code]$ dnf info gcc
      Last metadata expiration check: 0:08:51 ago on Tue Nov 21 23:49:09 2023.
      Available Packages
      Name         : gcc
      Version      : 11.3.1
      ...output omitted...
      Description  : The gcc package contains the GNU Compiler Collection version 11.
                   : You'll need this package in order to compile C code.
      ...output omitted...
    3. Install the gcc package. Use sudo privilege for the student user to perform the installation.

      Use student as the password.

      Press y to confirm the installation.

      [student@workstation Code]$ sudo dnf install gcc
      [sudo] password for student: student
      Last metadata expiration check: 0:16:59 ago on Tue Nov 21 23:43:13 2023.
      Dependencies resolved.
      ==================================================================================
       Package   Architecture  Version         Repository                          Size
      ==================================================================================
      Installing:
       gcc       x86_64        11.3.1-2.1.el9  rhel-9.1-for-x86_64-appstream-rpms  32 M
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
  5. Compile the code and run the resulting binary file.

    1. Compile the code by running the make command.

      [student@workstation Code]$ make
      gcc -c code.c -o code.o
      gcc code.o -o code
    2. Verify the resulting files.

      [student@workstation Code]$ ls -l
      total 40
      -rw-r--r--. 1 student student    78 Nov 22 00:46 Makefile
      -rwxr-xr-x. 1 student student 25792 Nov 22 00:50 code
      -rw-r--r--. 1 student student    78 Nov 22 00:50 code.c
      -rw-r--r--. 1 student student  1504 Nov 22 00:50 code.o
    3. Run the code binary file.

      [student@workstation Code]$ ./code
      Hello World!
  6. Review the package installation history. Return to the student user home directory.

    1. Review the package installation history

      [student@workstation Code]$ dnf history
      ID     | Command line               | Date and time    | Action(s)      | Altered
      ---------------------------------------------------------------------------------
          13 | install gcc                | 2023-11-22 00:30 | Install        |    5
          12 | install make               | 2023-11-22 00:00 | Install        |    1
          11 |                            | 2022-12-14 17:04 | Install        |    2
          10 |                            | 2022-12-14 17:04 | D, I           |   19
      ...output omitted...
    2. Return to the student user home directory.

      [student@workstation Code]$ cd
      [student@workstation ~]$

Finish

On the workstation machine, 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-packages

Revision: rh104-9.1-3d1f2bc