In this exercise, you will gather information about a package from a third party, extract files from it for inspection, and then install it on a server.
Outcomes
You should be able to install a package not provided by software repositories on a server.
Log in as the student user on workstation using student as the password.
From workstation run the lab software-rpm start command.
The script runs a start script that determines whether the host, servera, is reachable on the network.
The script also downloads the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student directory on servera.
[student@workstation ~]$lab software-rpm start
Use the ssh command to log in to servera 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 the package is installed or uninstalled.
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 -iName : rhcsa-script Version : 1.0.0 Release : 1 Architecture: noarch Install Date: (not installed) Group : System Size : 1056 License : GPL Signature : (none) Source RPM : rhcsa-script-1.0.0-1.src.rpm Build Date : Wed 06 Mar 2019 03:59:46 PM IST Build Host : foundation0.ilt.example.com Relocations : (not relocatable) Packager : Snehangshu Karmakar URL : http://example.com Summary : RHCSA Practice Script Description : A RHCSA practice script. The package changes the motd.
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/mymotd
View the script that runs when the rhcsa-script-1.0.0-1.noarch.rpm package is installed or uninstalled.
[student@servera ~]$rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm --scriptspreinstall 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 in 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 1056 Mar 6 15:59 ./opt/rhcsa-script/mymotd 3 blocks
Extract all files from the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student directory.
Use the rpm2cpio and cpio -idv commands to extract the files and create the leading directories where needed in verbose mode.
[student@servera ~]$rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -idv./opt/rhcsa-script/mymotd 3 blocks
List to verify the extracted files in the /home/student/opt directory.
[student@servera ~]$ls -lR optopt: total 0 drwxrwxr-x. 2 student student 20 Mar 7 14:44 rhcsa-script opt/rhcsa-script: total 4 -rw-r--r--. 1 student student 1056 Mar 7 14:44 mymotd
Install 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 the package is installed.
[student@servera ~]$rpm -q rhcsa-scriptrhcsa-script-1.0.0-1.noarch
Exit from servera.
[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$