Open main menu

CDOT Wiki β

Changes

OPS245 Lab 3 dev

41 bytes added, 16:16, 21 February 2023
INVESTIGATION 3: MANAGING SOFTWARE PACKAGES
= LAB PREPARATION =
*** UNDER DEVELOPMENT ***
{| width="40%" align="right" cellpadding="10"
|- valign="top"
<u>Main Objectives</u>
*Learn to boot your CentOS RHEL VM into '''Single User mode''' for rescue purposes
*Create and extract '''archive''' files ('''tar''' and '''tar.gz''')
*Install applications using various methods:
:*'''Download''', '''decompress''' and archive file from the Internet, then '''compile source code''' in order to install an application.
:*Use '''yumdnf''' utility to install software from '''local source programs''' (on DVD drive):*Use '''yumdnf''' utility to install software from '''repositories''' (online storage areas)
:*Learn how to '''add repositories''' (online software storage areas) to install less common applications.
<ul><li value="4">Demonstrate the use of Bash Shell scripts to automate routine tasks (generate a customized software report)</li></ul>
Software Manangement<br>
[https://linux.die.net/man/8/rpm rpm]<br>
[httphttps://man7.org/linux/man-pages/man8/yumdnf.8.html yumdnf]
| style="padding-left:20px;"|Miscellaneous
[http://man7.org/linux/man-pages/man1/ls.1.html ls]<br>
|- valign="top"
|
[[Image:grub1Rhel-grub_1.png|thumb|right|600px|Press '''e''' at Grub Boot Menu to edit]]
|}
===Part 1: Common Booting Issues===
'''A few common problems are:'''
*I Can't boot into Graphical Mode on my '''c7hostr9host''' machine
*I Forgot My '''Regular User''' Password
*I Forgot My '''root''' Password
|- valign="top"
|
[[Image:grub2_1Rhel-grub_2.png|thumb|right|600px|Add the boot option '''single''' and then press '''ctrl-x''' to boot into single user mode]]
|}
#Launch the VMware application.
#Select Open Virtual Machine, and select the VM called c7host r9host on your Solid State Drive.#Launch your '''c7hostr9host''' machine, and login as as a regular user.#Boot-up your '''centos1rhel1''' VM. ''' When the Grub Boot menu appears''', press the letter <b><code><span style="color:#3366CC;font-size:1.2em;">e</span></code></b> (for "edit").
#Using your arrow keys, scroll to next screen to '''linux''', or '''linux16''', or '''linux-efi''' command and type the word <b><code><span style="color:#3366CC;font-size:1.2em;">single</span></code></b> as an argument after '''quiet''' (see diagram for reference) and then press <b><code><span style="color:#3366CC;font-size:1.2em;">ctrl-x</span></code></b> to boot.
#The system should boot into text-based mode. Enter your '''root''' password.
|- valign="top"
|
[[Image:grub2_3Rhel-grub_3.png|thumb|right|600px|Add '''rw init=/sysroot/bin/sh''' as shown and then press '''ctrl-x''' to boot into single user no root password mode]]
|}
#The procedure to reset root's password is different than shown above.
#Make certain that your centos1 rhel1 VM that you used in Part 2 has been shutdown.#Start your centos1 rhel1 VM and press <b><code><span style="color:#3366CC;font-size:1.2em;">e</span></code></b> at the Grub boot menu.
#Using your arrow keys, move to '''linux''' or '''linux-efi''' command and replace the argument '''ro''' with the argument <b><code><span style="color:#3366CC;font-size:1.2em;">rw init=/sysroot/bin/sh</span></code></b> (see diagram for reference) and then press <b><code><span style="color:#3366CC;font-size:1.2em;">ctrl-x</span></code></b> to boot.
#The system should boot into text-based mode without prompting for root's password.
#To restart in graphical mode, simply enter the command <b><code><span style="color:#3366CC;font-size:1.2em;">exit</span></code></b>, then <b><code><span style="color:#3366CC;font-size:1.2em;">reboot</span></code></b>.
{{Admon/important | What To Do If Reboot Doesn't Work | In this mode, the reboot command may not work. If it doesn't, go to the top of the centos1 rhel1 VM window, select Send Key -> Ctrl+Alt+Delete.}}
===Catastrophic Boot Problems===
:Not being able to start your '''c7hostr9host''' due to '''Kernel Panic''' or some sort of '''catastrophic disk failure''' is not as easy to fix. You might be able to boot from your a '''Centos LIVE DVD, open a terminal and mount the partition''' via command line and look for possible problems (setup files like '''/etc/fstab'''). '''Lab5''' will discuss more about mounting and the /etc/fstab file. The "worst-case scenario" would be to purchase a new hard disk, '''perform lab1 completely, perform lab2 to install and set-up virtualization software''', then '''restore your VM image and xml file backups''' (eg. decompressing images, issuing virsh define commands for .xml files). That is why consistently '''performing backups of ALL of your VMS at the end of each lab is absolutely essential! You have been warned!'''
'''Answer INVESTIGATION 1 observations / questions in your lab log book.'''
 
= INVESTIGATION 2: ARCHIVING &amp; RESTORING FILES =
'''Perform the following steps:'''
#Boot up your '''centos3rhel3''' VM.#Tar may not be installed by default. Confirm by issuing the command '''which tar'''. If the output indicates tar is not on the system, install it with the following command. If it is found, skip the next step#Install tar (if it was missing) sudo dnf install tar
#Change your working directory to '''/usr/share/doc/sudo*'''
#Use the tar (tape archiverarchive) command to create an archive file named "/tmp/archive1.tar" by issuing the following command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">tar cvf /tmp/archive1.tar .</span></code></b>
{{Admon/important | Warning! | Don't miss the <code>.</code> at the end of the <code>tar</code> command (where indicated). It specifies what should go into the archive: the contents of the current directory.}}
'''Perform the following steps:'''
#Remain in your '''centos3rhel3''' VM.
#Create the directory '''/tmp/extract1'''
#Change to the '''/tmp/extract1''' directory.
{| width="40%" align="right" cellpadding="10"
|- valign="top"
|colspan="2"|{{Admon/note|Internet Connection|In order for the '''yum dnf install''' command to work you require a connection to the Internet.}}
|}
=== Part 1: Managing Software and Repositories with Yum DNF ===We will learn how to install software packages with the '''yumdnf''' utility. This command is useful for installing software since it automatically resolves software dependencies prior to installing the software. Upon your Centos RHEL OS installand registration, a link to a software repository is automatically made to allow for easy software updates.
Unfortunately, there is no guarantee that a particular software package is contained on the default repository. In order to overcome this problem, you can add other repositories that may contain the application that you wish to install.
'''Perform the following steps:'''
#Make certain that you are in your '''c7hostr9host''' machine.#Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum dnf install elinkslynx</span></code></b>#Now issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">yum dnf info elinkslynx</span></code></b>#How can you tell if the elinks lynx package has been installed?#To remove the elinks lynx package issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum dnf remove elinkslynx</span></code></b># Verify that the elinks lynx package has been removed. Also verify that the application called: # We will now look at how we can add different repositories to our '''xchatr9host''' is not installedmachine.# Use Issue the wget following command to download the xchat rpm binary from the following URL:::<b><code><span style="color:#3366CC;font-size:1.2em3em;">http://mirror.centos.org/centos/7/os/x86_64/Packages/xchat-2.8.8-25.el7.x86_64.rpmdnf repolist</span></code></b><br>::What do # Take a few moments to review the output. Do you think is see which repositories are used by the purpose of '''dnf''' command? Write down the numbers also contained repositories in the filename?your lab logbook. <ol><li value="8">Issue Next, we will add the command: '''epel repository''' (Extra Packages for Enterprise Linux) and install '''Alien'''. <b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum localinstall xchat-2.8.8-25.el7.x86_64.rpm</span></code></b></li><li>Verify that the '''xchatAlien''' command has been installedis a tool for converting packages for other package managers (such as debian, which end with .deb) to another (such as red hat, which end with .rpm).</li><li>Run the xchat application.</li></ol>
{| width="40%" align="right" cellpadding="10"Possible Packages to install from epel:|- valign="top"# Cinnamon|colspan="2"|{{Admon/tip|IRCs: A Great Tool for Linux Administrators|Although Search Engines (like Google) are a system administrator's good friend, Internet Relay Chats (IRCs) are also a great tool for system administrators to help obtain information. Many website offer information on how to connect to IRCs (both nodes (eg. FreeNode) and irc channel (eg. #linux). You can now use your newly-created application called '''xchat''' to do this.<br><br><u>'''A few tips to consider with IRCs'''</u>:<ul><li>Do your Homework (read docs first!)</li><li>Ask specific questions</li><li>Not all chats are friendly</li><li>Be patient when asking questions (use courtesy)</li><li>The advice is free (you get what you pay for!)</ul>}}|}Chromium
# To add the epel repository, issue the commands:<olbr><b><code><li valuespan style="11color:#3366CC;font-size:1.3em;">We will now look at how we can add different repositories to our '''c7host''' machinesudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms <br> sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm</span></licode><li/b>Issue the following command# Install alien: <b><code><span style="color:#3366CC;font-size:1.3em;">yum repolistsudo dnf install alien</span></code></b># To verify that you have added the repository, you can issue the command: <b><code><span style="color:#3366CC;font-size:1.3em;">dnf repolist</span></licode><li/b>Take a few moments to review the output. Do you see which repositories are used by # Also verify that the application called: '''yumpackettracer''' command? Write down the repositories in your lab logbookis not installed.</li><li>View the following link # Login to see a general listing of repositories:<br>[ [httphttps://wikiwww.centosnetacad.orgcom/AdditionalResources/Repositories Available Repositories for CentosCisco Netacad] ].</li><li>To add and download Packet Tracer '''Ubuntu Desktop Version'''# Launch a terminal and change to the directory where you downloaded the epel repository, issue package (likely your Downloads folder)# Issue the following commandconvert the .deb package to an rpm using Alien (this may take a few minutes, be patient):<br><b><code><span style="color:#3366CC;font-size:1.3em2em;">sudo yum install epelalien -releaser CiscoPacketTracer_*</span></code></b></li><li>To verify that you have added # List the repository, contents of your directory. What changed? What do you can issue think Alien did?# Issue the command: <b><code><span style="color:#3366CC;font-size:1.3em2em;">yum repolistsudo dnf localinstall xchat-2.8.8-25.el7.x86_64.rpm</span></code></b></li><li># Verify that the '''xchat''' command has been installed.# Run the xchat application# Unused and unneeded software can present a security risk and ties up disk space needlessly. Find '''at least 4 other packages''' to remove on your c7host r9host machine(for example: '''sound & video''', '''games''', etc) that you're not using on your system. '''Be careful ''' to ensure that removing those packages does not also remove other software that you do need.</li></ol>
===Part 2: Compiling Source Code from a Downloaded Archived File===
Sometimes, some software may <u>not</u> be available on repositories to install with the '''yumdnf''' command. They may be available from web-pages to download, and compile. Now that you know how to create and decompress "zipped tarball archives", we will demonstrate how to install applications from websites containing these types of archives. Although this method is not as "user-friendly" as using the yum command, this method is useful if the application is NOT contained in regular software repositories...
In order to build software from source code, you must have the appropriate software development tools (such as make and gcc) and libraries (such as GTK) installed. The required tools will vary depending on the computer languages used in the software being built.
'''Perform the following steps:'''
# Remain in your '''c7hostr9host''' VM, but make certain that you are logged in as a regular user (i.e. NOT root!).# Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">which lbreakout2lbreakouthd</span></code></b><br>Is there a program called '''lbreakout2''' on your system?# Perform an Internet search for the pattern: <b><code><span style="color:#3366CC;font-size:1.2em;">lbreakout2 lbreakouthd tar.gz</span></code></b># Go to an appropriate webpage and download a "zipped tarball" (compressed source code) for the '''lbreakout2lbreakoutHD''' game (filename should be something like: '''lbreakout2-2.6.5.tar.gz''')
#Change to the directory where you downloaded that file (most likely ''~/Download''s).
# Use the '''tar''' command to decompress the "zipped tarball" called something like (not may be exactly): '''lbreakout2lbreakouthd-21.61.51.tar.gz'''.# Change to the directory that contains that ''lbreakout2lbreakouthd'' source code.
{| width="40%" align="right" cellpadding="10"
|- valign="top"
<ol>
<li value="8">Issue the following command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">./configure && make</span></code></b><br>Most likely, you will get an '''ERROR!''' What do you think the error is telling you?<br></li>
<li>Issue the following command to install the files for application development by issuing the command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum dnf groupinstall "Development Tools"</span></code></b></li>
<li>Issue the command in step 7. You should get another ERROR! What dependency is missing?</li>
<li>Issue the following command to install the library files for SQL by issuing the command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum dnf install SDL-devel libpng-devel zlib-devel</span></code></b></li>
<li>Reissue the <b><code><span style="color:#3366CC;font-size:1.2em;">./configure && make</span></code></b> command. Were you successful?</li>
<li>Run the command <b><code><span style="color:#3366CC;font-size:1.2em;">lbreakout2lbreakouthd</span></code></b>. Were you successful?</li>
<li>You need to run a command to make this program available regardless of your current directory (as opposed to running command in the directory that contains the program). So, issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">sudo make install</span></code></b></li>
<li>Run the command: <b><code><span style="color:#3366CC;font-size:1.2em;">lbreakout2lbreakouthd</span></code></b>. Did it work? Issue the command:<br> <b><code><span style="color:#3366CC;font-size:1.2em;">which lbreakout2</span></code></b>. What do you think that the '''make install''' command did?</li>
</ol>
'''Perform the following steps:'''
<ol>
<li> Use your '''c7hostr9host''' VM for this section.</li>
<li>Open a Bash terminal and run the command:
'''Perform the Following Steps:'''
# Make certain that your '''c7hostr9host''' and '''centos3rhel3''' VMs are running.# Switch to your <u>'''c7hostr9host'''</u> machine, open a shell terminal as a regular user, and change to the directory: '''~/bin'''
# Download the Lab 3 check script: <b><code><span style="color:#3366CC;font-size:1.2em;">wget https://raw.githubusercontent.com/OPS245/labs/main/lab3-check.bash</span></code></b><!--<br>For Andrew's sections use this script instead: <b><code><span style="color:#3366CC;font-size:1.2em;">wget http://littlesvr.ca/ops245/lab3-check-andrew.bash</span></code></b>-->
# Give the '''lab3-check.bash''' file execute permissions (for the file owner).
# Run the shell script with <code>sudo</code>, and if any warnings appear, fix the issues noted by the script and rerun the check until you receive the "Congratulations!" message.
# Arrange proof of the following on the screen:<br><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos3rhel3''':<blockquote><ul><li> Archived files '''created'''</li><li>Archive files '''restored'''</ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''c7hostr9host''':<blockquote><ul><li> '''One repository added''' for yumdnf</li><li>Run the '''lab3-check.bash''' script (must have all <b><code><span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span></code></b> messages)</li></ul></blockquote><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab 3''' logbook pages filled out.
# Upload a screen of the proof from the previous step, along with the file generated by '''lab3-check.bash''', your log book, and your '''tarchiver.py''' script to blackboard.
#What does yum do that compiled source code does not?
#Other than running an installed package, what commands can you issue to verify that the package was installed?
#List the steps to remove a package via yum dnf command.#List the steps to install a package using the yum dnf command.#List the steps to add a repository to be used with yumdnf.#What is the command to list all repositories associated with the yum dnf command?
#What is the command to view all repositories that have been added to-date?
#How do you use the '''sed''' command to modify text?