1,234
edits
Changes
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE COURSE. This page will no longer be updated.|'''Debian version here:''' https://seneca-ictoer.github.io/OPS245
<br>'''CentOS version here:''' https://seneca-ictoer.github.io/OPS245-C7<br>'''Andrew's version here:''' http://wiki.littlesvr.ca/wiki/OPS245_Lab_3}}
= LAB PREPARATION =
{| width="40%" align="right" cellpadding="10"
#Select Open Virtual Machine, and select the VM called c7host on your Solid State Drive.
#Launch your '''c7host''' machine, and login as as a regular user.
#Boot-up your '''centos1''' VM. '''when 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.
[[Image:grub2_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]]
|}
===Part 3: Resetting Forgotten Root Password===
#The system should boot into text-based mode without prompting for root's password.
#Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">chroot /sysroot</span></code></b><br>
#Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">passwd root</span></code></b> in order to change your root password (press '''ctrl-c''' if you wish to abort - i.e. not change password).<br>'''NOTE:''' if you are using SELinux in '''enforcing''' or '''permissive''' mode, you will also need to issue the command: '''touch /.autorelabel''' <br>This may take some time depending on the amount of files you have on the file system (usually about 2 minutes).
#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>.
# Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">which lbreakout2</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 tar.gz</span></code></b>
# Go to an appropriate webpage and download a "zipped tarball" (compressed source code) for the '''lbreakout2''' 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): '''lbreakout2-2.6.5.tar.gz'''.
# Change to the directory that contains that ''lbreakout2'' source code.
{| width="40%" align="right" cellpadding="10"
<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 groupinstall "Development Tools"</span></code></b></li>
<li>Issue the command in step 78. 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 install SDL-devel</span></code></b> (possibly <b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum install libpng-devel</span></code></b> and <b><code><span style="color:#3366CC;font-size:1.2em;">sudo yum install 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;">lbreakout2</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). Login as root (be sure to be in the same directory as the source code after logging in as root) and So, issue the command:<br><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;">lbreakout2</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>
<br>
<code><span style="color:#3366CC;font-size:1.1em;"><b>
# Use sed with extended regular expressions to only print those matching report elements<br>
rpm -qi xchat
</b></span></code><<br />Notice that using the '''-i ''' option with '''-q ''' causes rpm to generate more output than we have seen from it so far.</li><li>Pick any five packages and run the <code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qi</b></span></code> command on all five at once. This should produce dozens of lines of output. Consider the output it would generate if we used -a instead of picking just a few packages.<li><li>Run <code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qia</b></span></code> now.)</li>
<li>That is way too much output for us to reasonably search through, but we have commands that can filter this down to a much more readable amount.</li>
<li>Try the command: <br><code><span style="color:#3366CC;font-size:1.1em;"><b>rpm -qia | sed -nre '/^Name[[:space:]]+:/ p' -e '/^Install Date[[:space:]]*:/ p'</b></span></code><br />
Instead of printing every line, this will only display the name and install date of each package.</li>
<li>Try modifying that command to display only the package name Name and License.</li>
</ol>
<li>Add a third prompt (immediately after the other two prompts and before the tar command), asking the user if they want the archive to be compressed. You'll need an if statement to run your tar command with gzip compression if they answered yes.</li>
<li>Test your script to make sure it works.</li>
<li>Add a fourth prompt asking the user what type of compression they want (present them with gzip, bzip2, and xz xzip as options). Note that this prompt should only be shown if the user opted for compression (if they don't want compression, there is no point asking what type they don't want).</li>
<li>Expand the if statement around your actual tar command to use whichever type of compression the user asked for.</li>
<li>Test your script to make sure it works.</li>
<li>Test your script again, but feed it nonsense data (e.g. answer 'very much so' instead of 'y' or 'n' when prompted about compression).</li>
<li>Add loops around your prompts for whether or not the user wants compression, and the compression type to make the script repeat each prompt until the user gives a response your script can actually use. Don't worry about doing anything with the archive name or path.</li>
<li>Now test your script again, with good data and with nonsense.</li>
<li>When you are confident your script works, you are ready to submit the lab.</li>
# Make certain that your '''c7host''' and '''centos3''' VMs are running.
# Switch to your <u>'''c7host'''</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://ictraw.senecacollegegithubusercontent.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/labs/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.