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
Navigate to the Code directory.
Try to run the make command.
The make command compiles code and builds an executable file.
Navigate to the Code directory.
[student@workstation ~]$ cd CodeTry 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.
Search for and review information about the make package.
Search for the make package by using the dnf command.
[student@workstation Code]$dnf search makeRed 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.
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...Install the make package and try to run the make command.
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:studentLast 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!
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-rpmsTry to run the make command.
[student@workstation Code]$makegcc -c code.c -o code.o make:gcc: No such file or directorymake:*[Makefile:4: code.o] Error 127
The command returns an error because the compiler cannot find the gcc library.
Search for and install the gcc package.
Search for the gcc package by using the dnf command.
[student@workstation Code]$dnf search gccRed 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.
Obtain information about the gcc package.
[student@workstation Code]$dnf info gccLast 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...
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:studentLast 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!
Compile the code and run the resulting binary file.
Compile the code by running the make command.
[student@workstation Code]$ make
gcc -c code.c -o code.o
gcc code.o -o codeVerify the resulting files.
[student@workstation Code]$ls -ltotal 40 -rw-r--r--. 1 student student 78 Nov 22 00:46 Makefile -rwxr-xr-x. 1 student student 25792 Nov 22 00:50code-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
Run the code binary file.
[student@workstation Code]$ ./code
Hello World!Review the package installation history.
Return to the student user home directory.
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...Return to the student user home directory.
[student@workstation Code]$ cd
[student@workstation ~]$