Changes

Jump to: navigation, search

OPS245 Lab 1 dev

1,210 bytes removed, 22:53, 14 February 2023
no edit summary
=LAB PREPARATION=
[[Image:vmware-1a-rhel.png|thumb|right|450px|The VMware Workstation application will allow you to create and administer '''4 different virtual machines''' ('''VM'''s) on your computer system. ]]
===Purpose of Lab 1===
| |[[Image:ssd.png|thumb|left|175px|<b>Solid State Drive</b><br>Minimum Size: 250GB]]
| [[Image:log-book.png|thumb|left|100px|<b>Lab Logbook</b><br>[[:Media:OPS245-Logbook-Online.doc|(lab 1Click Here to Download)]]]]
| style="padding-left:15px;" |Package Management
| style="padding-left:15px;"|Matrix on-line tutorials<br><ul><li>Linux Basics:<br>'''/home/ops235/linux-basics'''</li><li>Using the vi Text Editor:<br>'''/home/ops235/vi-tutorial'''</li><li>Shell Scripting - Part I (Scripting Basics):<br>'''/home/ops235/scripting-1'''</li></ul>
|}
 
= INVESTIGATION 1: CREATING A RED HAT ACCOUNT AND DOWNLOADING THE ISO =
'''<u>r7host r9host VM Details:</u>'''
*'''Name:''' r9host
|-
|
[[Image:partition_verificationRhel_Partition_verification.png|thumb|right|450px|Carefully verify partition mount-names and sizes prior to proceeding with install. Check [http://matrix.senecac.on.ca/~murray.saul/ops235/installation/ installation screenshots] link for verification.]]
|}
::'''Connect to Red Hat:'''<ul><li>Enter the '''User name''' and '''Password''' for the account you created in '''Investigation 1'''.</li><li>Under '''Purpose''' Check the box that says '''Set System Purpose'''</li><li>For '''Role''' select '''Red Hat Enterprise Linux Server'''</li><li>For '''SLA''' select '''Self-Support'''</li><li>For '''Usage''' select '''Production'''</li><li>Check the box that says '''Connect to Red Hat Insights'''</li><li>Click '''Register'''. This may take a few minutes.</li><li>Click '''Done'''.</li></ul><br>
::'''User Settings:'''
::Click '''Create User'''<olul><li>Enter your name</li><li>Set your username</li><li>Set your Password</li><li>Check the box beside '''Make this user administrator'''</li></olul>
::Leave the Root account '''disabled''' (ie do not set a password)
<br>
::'''INSTALLATION DESTINATION:'''
::*From the installation summary screen, click '''Installation Destination'''.
{|width="40%" align="right" cellpadding="10"
|- valign="top"
|[[Image:completedRhel_completed.png|thumb|right|500px|This screen indicates that installation is complete. ]]
|}
:'''Perform the Following Steps:'''
#During the *When installation processis complete, you will required to create notice a message at the bottom of the screen stating: '''root password''' (Red Hat Enterprise Linux is now successfully installed and ready for administration access) and create a you to use!'''regular user account'''. *Click on the '''Root PasswordReboot''' and enter your root passwordbutton. Think of an appropriate password and record that password somewhere in case you forget! An indicator Your DVD will appear to show you how secure your password is. Retype your root password and click '''Done''' (you may have to click Done <u>twicebriefly</u> open in the DVD drive bay (if your password is not considered to be you are using a strong passwordphysical DVD).#You need Make certain to create a regular user account. This account remove this installation DVD so that CentOS will be used to graphical log into boot from your host machinehard drive. It is never recommended to graphically log into *After the system reboots, a graphical Linux/Unix boot menu should briefly appear.*The system as root. It is better should then graphically prompt the user to log into a login with their regular user account, then run a command with temporarily elevated privileges (you will learn how to do this later in this lab).#Click '''User Creation''' and enter on your '''full regular user account name''', '''username''', and an appropriate '''enter your regular user password''' (and confirm password). Make sure the box labelled 'Make this user administrator' is checked. Click *Start using your installed Linux system by clicking '''DoneStart Using Red Hat Enterprise Linux''' .*Open a web-browser and check to finish (click twice see if password is not considered you can connect to be a strong password)the Internet.<br><br>{|width="50%" cellspacing="0"
|- valign="top" |{{Admon/important|Keep the root password the same for Host and VMs|In order to simplify running the lab checking scripts in future labs, using the same root password for ALL machines (c7host and virtual machines). Also use the same username and passwords for all of your machines (c7host and virtual machines). <b>Do not do this in a production environment!</b>}}<br><br>|}<ol><li value="4">When installation is complete, you will notice a message at the bottom of the screen stating: '''CentOS is now successfully installed and ready for you to use!'''</li><li>Click the '''Reboot''' button. Your DVD will <u>briefly</u> open in the DVD drive bay. Make certain to remove this installation DVD so that CentOS will boot from your hard drive.</li><li>After the system reboots, a boot menu should briefly appear, then prompt the user to accept the License Information (this is only a one-time occurrence).<br> In order to accept the license agreement, Click on '''License Not Accepted''' and graphically accept the license and then click '''FINISH CONFIGURATION''' to finish the installation process.<br><br>'''NOTE:''' If you have an older version of CentOS 7, you must perform the alternative steps:<br>Issue the following keystrokes:<br><br>'''1''' followed by ENTER (to select the license agreement prompt<br>'''2''' followed by ENTER (to accept the license agreement)<br>'''c''' followed by ENTER (to save the selection)<br>'''c''' followed by ENTER (a second time to continue booting into the system)<br><br></li><li>The system should then graphically prompt the user to login with their regular user account. Click on your '''regular user account name''' and '''enter your regular user password'''.<br><br></li><li>The last phase of the installation process should now run:<ul><li>Confirm English as the default input source and click '''Next'''.</li><li>Skip the creation of online accounts by clicking '''Next'''.<li>Start using your installed Linux system by clicking '''Start Using CentOS Linux'''.</li></ul><br></li><li>Open a web-browser and check to see if you can connect to the Internet.</li></ol> '''Answer Investigation 1 2 observations (all parts and questions) in your lab log book.'''
=INVESTIGATION 3: Common Post-Installation Tasks=
===Managing your Virtual Machine===
In future labs, you will have to run your VMware Workstation application to boot-up your CentOS 7 RHEL9 host VM.Usually, you are NOT required to use this menu (unless you need to "force-off" the c7host7 r9host machine, but should only be performed if you cannot normally shut-down the c7host r9host VM from the OS.
On the other hand, there are useful short-cut key you should use:
'''ALT-CTRL'''
:Return focus from your c7host r9host VM to your '''host computer system'''.
{{Admon/caution|Properly Exiting CentOS 7 RHEL 9 Session and Safely Removing USB Device|It is '''ABSOLUTELY ESSENTIAL''' that you do '''NOT''' remove your SSD drive during your CentOS 7 RHEL 9 session. You are required to correctly shutdown your CentOS 7 RHEL 9 host virtual machine as you would with any operating system. Also, you are required to use the '''Safely Remove Hardware and Eject Media''' tool in the system tray on your Windows machine to properly disconnect your SSD device.
<br><br>'''FAILURE TO DO THIS MAY DAMAGE YOUR HOST VM AND NOW ALLOW IT TO BOOT PROPERLY (YOU HAVE BEEN WARNED)'''.}}
#Refer to the Information box regarding how to access administrative privileges from the command line.
#Open a Terminal by clicking on '''Activities''' in the top left corner, then selecting '''Terminal''' from the menu in the bottom centre of your screen.
#Issue the command <b><code><span style="color:#3366CC;font-size:1.3em;">whoami</span></code></b>. This will display the name of your currently logged in user.
#Issue the command <b><code><span style="color:#3366CC;font-size:1.3em;">sudo whoami</span></code></b>. The first time you run any command with sudo, you will receive a warning asking you if you know what you are doing (i.e. running a command with the privileges of the root account). It will then prompt you for your password (the one for the account running the command through sudo, not the root account). If you enter your password correctly, sudo will run the command as the '''root account'''. This time the command will return '''root''', showing the elevated privileges.
# Open Terminal.
# Type: <b><code><span style="color:#3366CC;font-size:1.3em;">sudo yum dnf update</span></code></b>
# Follow the prompts.
# If there is a kernel update, reboot your system. (There usually is on a first update after OS installation.)
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;"><b><code><span style="pointer-events: none;cursor: default;color:#3366CC;font-size:1.2em;">ip address show</span></code></b><br><b><code><span style="pointer-events: none;cursor: default;color:#3366CC;font-size:1.2em;">ip route show</span></code></b><br><b><code><span style="pointer-events: none;cursor: default;color:#3366CC;font-size:1.2em;">nslookup</span> (at prompt, enter command: server. When you are done type exit.) </code></b></td>
<td width="20%" style="border-bottom: thin solid black;">Obtain network connectivity confirmation including: '''IP ADDRESS''', '''Netmask''', '''routing''' (default gateway), and the default '''Domain Name Server'''.</td>
</tr>
<li>View the ''report.txt'' contents. You should be able to understand them because you just put that content there, but what would this look like if you look at the file several months from now? In order to make this file more readable, use the command line to add a blank line between the output from each command, and a header before each command briefly describing what the output is (note that this will likely require re-running all of these commands).</li></ol>
'''Answer Investigation 3 4 observations (all parts and questions) in your lab log book.'''
= INVESTIGATION 5: Using Python Scripting to Generate System Information Reports =
:'''Perform the Following Steps:'''
<ol>
<li>Install Check if python3 is installed on your Centos RHEL Host machine. Open a terminal and type:</li>
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
which python3</code><li>The output should of the previous command should show python3 is already installed. If it is not, install python3 on your RHEL Host machine.</li><code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">sudo yum dnf install python3
</code>
<li><ul><li>Create a new file in your '''~/bin''' directory called '''myreport.py'''</li>
<li>Add a line that will print out the heading '''System Report'''<br />
<code style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;font-weight:bold;">
print('System Report\n')
</code>
</li>
<li>Save your script and run it. Does it work?</li>
<li>You'll notice that the python script is currently sending its output to your terminal. Since we haven't covered how to write to a file yet, this is ok for now. Just use output redirection on the command line when you run the script to send the output to '''~/bin/pythonreport.txt'''.</li>
<li>Add Open your script in a text editor (like Vi) again, and add the following lines below the print statement:</li><pre style="color:#3366CC;font-family:courier;font-size:.9em;margin-left:20px;>&#35; Import the Operating System moduleimport os &#35; Print a heading for the date command outputprint('Current Date:') &#35; Call the date command using the os moduleos.system("date +'%A %B %d, %Y (%I:%M %p)'")</pre><li>Save your script and run it again. Observe the output. What do you think the os.system command did?</li><li>Based on the above example and output, add the extra commands for your python script to also output (with appropriate headings):
<ul>
<li>The current date.</li>
<li>The hostname of the machine.</li>
<li>The kernel version.</li>
</ul>
</li>
<li>Run your script to make sure it works. Note that the output does not need to match investigation 3 4 exactly, but it should be very close.</li>
</ol>
Shell scripting is <u>so essential</u> for Linux administration that this course has created a shell script for every lab for this course that a student must download and run in order to check their work.
If you have performed the lab correctly, then you will get a series of <b><code><span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span></code></b> messages and you can proceed with the SIGN-OFF for lab1. On the other hand, if there were errors, then a <b><code><span style="color:#ff0000;border:thin solid black;font-size:1.2em;">&nbsp;WARNING&nbsp;</span></code></b> message will appear with general suggestions that you will need to fix on your c7hostVM r9hostVM in order to have your professor sign-off in this lab in order to proceed to the next lab.
:'''Perform the Following Steps:'''
# Make certain that your '''c7hostr9host''' VM is running, open the Bash Shell terminal.<br><br># Change to the '''~/bin''' directory.# Install git by issuing the following command: <code>sudo dnf -y install git</code># Download all the lab check scripts into your bin directory: <brcode>git clone https://github.com/ops245/labs/ /home/your-seneca-id/bin<br/code><!-- #Download the checking script by issuing the following Linux command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">wget https://raw.githubusercontent.com/OPS245/labs/main/lab1-check.bash</span></code></b><br><!--For Andrew's sections use this script instead:<br><b><code><span style="color:#3366CC;font-size:1.2em;">wget http://littlesvr.ca/ops245/lab1-check-andrew.bash</span></code></b><br>--><br># Give that downloaded shell script file execute permissions (for the file owner).<br><br># Run the shell script using '''sudo''' and if there are any warnings, make fixes and re-run shell script until you receive a "congratulations" message.: <brcode>sudo ./lab1-check.bash<br/code>#Arrange evidence (command output) for each of these items on your screen:
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Run the '''lab1-check.bash''' script (must have all <span style="color:#66cc00;border:thin solid black;font-size:1.2em;">&nbsp;OK&nbsp;</span> messages, and the congratulations message)
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Proof that c7host r9host VM is set for '''virtualization''' (Refer to: '''INVESTIGATION 12''' - '''Part 1''' - '''Step #29''')
: 78. Take a screenshot of the evidence and upload it, the file generated by the lab1-check.bash script, your logbook, and your myreport.py to blackboard.
= Practice For Quizzes, Tests, Midterm &amp; Final Exam =
# Define the term Virtual Machine.
# List the major screens (steps) in the installation of CentOS 7 Red Hat Enterprise Linux 9 full install DVD.
# What key-combination is used to toggle the view of your running VM from "window-mode" to "full-screen-mode"?
# List the steps for setting SELinux to permissive mode.

Navigation menu