In this exercise, you gather information about a package from a third party, extract files from it for inspection, and then install it on a server.
Outcomes
Install on a server a package that is not from the software repositories.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start software-rpm
Instructions
Use the ssh command to log in to the servera machine as the student user.
[student@workstation ~]$ ssh student@servera
...output omitted...
[student@servera ~]$View package information and list files in the rhcsa-script-1.0.0-1.noarch.rpm package.
Also view the script that runs when you install or uninstall the package.
View information for the rhcsa-script-1.0.0-1.noarch.rpm package.
[student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -i
Name : rhcsa-script
Version : 1.0.0
Release : 1
Architecture: noarch
Install Date: (not installed)
Group : System
Size : 593
License : GPL
Signature : (none)
Source RPM : rhcsa-script-1.0.0-1.src.rpm
Build Date : Wed 23 Mar 2022 08:24:21 AM EDT
Build Host : localhost
Packager : Bernardo Gargallo
URL : http://example.com
Summary : RHCSA Practice Script
Description :
A RHCSA practice script.
The package changes the motd.The preceding package modifies the MOTD, or "Message of the Day". A system displays the MOTD to users as they log in to systems.
List files in the rhcsa-script-1.0.0-1.noarch.rpm package.
[student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -l
/opt/rhcsa-script/mymotdView the script that runs when you install or uninstall the rhcsa-script-1.0.0-1.noarch.rpm package.
[student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm --scripts
preinstall scriptlet (using /bin/sh):
if [ "$1" == "2" ]; then
if [ -e /etc/motd.orig ]; then
mv -f /etc/motd.orig /etc/motd
fi
fi
postinstall scriptlet (using /bin/sh):
...output omitted...Extract the contents of the rhcsa-script-1.0.0-1.noarch.rpm package to the /home/student directory.
Use the rpm2cpio and cpio -tv commands to list the files in the rhcsa-script-1.0.0-1.noarch.rpm package.
[student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -tv
-rw-r--r-- 1 root root 593 Mar 23 08:24 ./opt/rhcsa-script/mymotd
2 blocksExtract all files from the rhcsa-script-1.0.0-1.noarch.rpm package to the /home/student directory.
Use the rpm2cpio and cpio -idv commands to extract the files and create the parent directories where needed in verbose mode.
[student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -idv
./opt/rhcsa-script/mymotd
2 blocksList the files in the /home/student/opt directory to verify that the extracted files are the same as the files inside the package.
[student@servera ~]$ ls -lR opt
opt:
total 0
drwxr-xr-x. 2 student student 20 Mar 23 09:22 rhcsa-script
opt/rhcsa-script:
total 4
-rw-r--r--. 1 student student 593 Mar 23 09:22 mymotdInstall the rhcsa-script-1.0.0-1.noarch.rpm package.
Use the sudo command to gain superuser privileges to install the package.
Use the sudo rpm -ivh command to install the rhcsa-script-1.0.0-1.noarch.rpm RPM package.
[student@servera ~]$sudo rpm -ivh rhcsa-script-1.0.0-1.noarch.rpm[sudo] password for student:studentVerifying... ################################# [100%] Preparing... ################################# [100%] Updating / installing... 1:rhcsa-script-1.0.0-1 ################################# [100%] [student@servera ~]$
Use the rpm command to verify that you correctly installed the package.
[student@servera ~]$ rpm -q rhcsa-script
rhcsa-script-1.0.0-1.noarchExit from the servera machine and connect again to test the new message of the day.
[student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$ssh student@servera______ _ _ _ _ _____ _ _ | ___ \ | | | | | | | | |_ _| (_) (_) | |_/ /___ __| | | |_| | __ _| |_ | |_ __ __ _ _ _ __ _ _ __ __ _ | // _ \/ _` | | _ |/ _` | __| | | '__/ _` | | '_ \| | '_ \ / _` | | |\ \ __/ (_| | | | | | (_| | |_ | | | | (_| | | | | | | | | | (_| | \_| \_\___|\__,_| \_| |_/\__,_|\__| \_/_| \__,_|_|_| |_|_|_| |_|\__, | __/ | |___/ Activate the web console with: systemctl enable --now cockpit.socket Register this system with Red Hat Insights: insights-client --register Create an account or view all your systems at https://red.ht/insights-dashboard Last login: Wed Mar 23 09:21:26 2022 from 172.25.250.9 [student@servera ~]$
Return to the workstation system as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$This concludes the section.