Open main menu

CDOT Wiki β

Changes

OPS245 Lab 1 dev

582 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>c7host r9host VM Details:</u>'''
*'''Name:''' c7hostr9host*'''Boot media / Installation:''' CentOS 7 RHEL 9 Full Install DVD (image file):::[https://mirror.senecacollege.ca/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso Download at Seneca Lab]:::[https://mirror.netflash.net/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso Download from Home](Acquired in Investigation 1)
*'''Disk space:''' 238GB
*'''CPUs:''' 1 CPU, 4 cores ('''Do not mix and match! Always use 1 CPU, and multiples of 2 for cores.''')
Before you can install your CentOS RHEL Full Install DVD onto your Virtual Machine, you must first create a storage container which is a virtual machine that will provide a platform for you to install your CentOS RHEL operating system.
:'''Perform the Following Steps:'''
[[Image:vmware-2.png|thumb|right|500px|'''Main WMware application window''' in order to create a new '''Virtual Machine''' ('''VM''')]]
<!-- # Although the images may be a little out of date (i.e. not exact), you can refer to this listing of installation screenshots for general reference:<br>[[http://matrix.senecac.on.ca/~murray.saul/ops235/ssd2/ installation screen-shots] ]<br> -->
# Power up the computer in your Seneca lab in '''Windows'''.
# If you haven't already downloaded the CentOS 7 RHEL 9 Full Install DVD ISO, then do so now.
# Plug your SSD drive into your computer. Note the drive letter for that device.
# Format your SSD to use exFAT, '''not NTFS'''. Open ''My Computer'', right-click on the SSD, and select ''Format...''. The dialog box should have the '''exFAT''' option selected, as the example to your right shows. Once selected, click ''Start''.
# Run the '''VMware Workstation Pro''' application (do '''<u>NOT</u>''' run VMware Player!).
# <span style="background-color:yellow;">In your VMware Workstation application window, click the '''Edit''' menu, then select '''Preferences'''. Under the '''Default Location For Virtual Machines''', enter the pathname for the newly created folder in your SSD device and click '''OK'''</span>.
# Click on the item labelled '''Create a New Virtual Machine'''.<br><br>'''NOTE:''' We will just be creating a "shell" for the VM to contain our CentOS 7 RHEL 9 Linux operating system.<br>This will allow us to configure the VM properly so it will boot-up properly in our Seneca labs.<br><br>
# Select the '''Custom (advanced)''' for the Virtual Machine Configuration setting and click '''Next'''.
# Click '''Next''' at the next screen to proceed.
# Select the '''I will in<u>s</u>tall the operating system later''' option and click '''Next'''.
# In the next screen, select '''Linux''' as the '''Guest Operating System''', and '''CentOS 7 Red Hat Enterprise Linux 8 64-bit''' for the OS ''version'' and click '''Next'''.# Enter '''c7hostr9host''' for the ''<u>V</u>irtual machine name'' and note the location where the image will be stored on your Windows machine and click '''Next'''.<br><br>'''NOTE:''' Since this "virtual machine" will be supporting other virtual machines (i.e. nested VMs), it is recommended to select a '''higher number or core processors''' (like 2 or 3).<br>You can always change this setting later on to maximize the performance of running the "nested" VMs on your Host VM.<br><br>
# Select <b>1 CPU, 4 cores</b> and click '''Next''' .
# In the following screen, change the Memory from ''1GB'' to '''8GB''' (i.e. '''8192 MB''') and click '''Next'''.
# Click '''Next''' to accept ''Create New Virtual Disk''.
# Change the Maximum Disk Size from ''20GB'' to '''238GB''' and click '''Next'''.
# Accept the default Disk File name (i.e. c7hostr9host.vmdk) and click '''Next'''.
# Quickly review your VM settings in the final setup wizard dialog box and click '''Finish'''.
# You should now see a detailed screen for your '''c7hostr9host''' VM on the right-hand side.<br><br>
{{Admon/caution|ATTENTION| PRIOR to proceeding, you MUST perform the following step <u>BEFORE</u> starting your Host VM in order to allow your Host VM to run correctly!!!<br>Students that do not follow these procedures exactly will run in to problems when trying to perform lab2 !!! You have been warned!!!.}}
<br><br>
<ol><li value="27">Make certain that your Host VM is <u>'''NOT'''</u> powered on before proceeding!</li>
<li>In the right-hand window (below "c7hostr9host"), and below ''"Power on this virtual machine"'', click the link called '''Edit virtual machine settings'''.</li><li><span style="background-color:yellow">In this setup dialog box, click the '''options''' tab and then click the '''Advanced''' option at the bottom of the list. On the right-hand side, under ''Firmware Type'', '''select the radio button for UEFI'''. Then click on the '''Hardware''' tab, and then select the '''CD/DVD (IDE)''' device and select in the right-side select the radio button for the '''use ISO Image file'''. Click the '''Browse''' button and specify the path of your downloaded CentOS 7 RHEL 9 Full install DVD (most likely file is contained in your Downloads folder). Click '''Processors''', and click the check-box to <u>enable</u> '''Virtual Intel VT-X/EPT or AMD-V/RVI'''. When finished, click on the '''OK''' button</span>.</li><li>You will return to your c7host r9host VM. Click '''Power on this virtual machine''' icon near the top to boot your c7host r9host VM to start your c7host r9host VM, and proceed to Part 2.</li>
</ol>
===Part 2: Install CentOS RHEL on your Newly-Created VM ===
The next step is to perform a custom installation for your CentOS 7 RHEL 9 virtual machine using the CentOS 7 RHEL 9 Full DVD. Upon creation of your c7host r9host virtual machine, The VMware Workstation application will automatically simulate a "boot" to allow you to complete the installation process to create the CentOS 7 RHEL 9 operating system on that virtual machine.
:'''Perform the following steps:'''
[[Image:installation_summaryRhel_Installation_summary.png|thumb|right|400px|The '''Installation Summary''' screen provides flexibly when configuring to install on your computer. ]]# Select from the installation menu: '''Install CentOS 7Red Hat Enterprise Linux 9'''.
# Next, you will be prompted for a language. In the first screen, select language '''English''' with subselection '''English-Canada''' and then click the '''Continue''' button on the bottom right-hand screen.
# The '''Install Summary''' should now appear. This screen allows the installer to customize their CentOS 7 RHEL 9 system prior to installation.
# Configure the following installation settings from the ''Install Summary Screen'':<br><br>
::<b>DATE & TIME:</b><ul><li>Click on the Map to select Toronto area (you may also select from the drop-down menu section)</li><li>Click the <b>DONE</b> button at the top-left corner to finish and return to the Installation Summary screen.</li></ul><br>
::<b>SOFTWARE SELECTION:</b><ul><li>Select the software packages labelled: <b>Gnome DesktopServer with GUI</b></li><li>Click the <b>DONE</b> button at the top-left corner to finish and return to the Installation Summary screen.<br><br></li></ul>::<b>NETWORK & HOSTNAME (you may need to scroll downwards):</b><ul><li>Select the default Ethernet connection and click the button on the top right-hand side to change the setting from <b>OFF</b> to <b>ON</b>.</li><li>'''Also, at the bottom left-hand corner''', type the hostname: <b>c7hostr9host</b> (all lowercase letters)</li><li>Review your settings, then click the <b>DONE</b> button at the top-left corner to finish and return to the Installation Summary screen.</li></ul><br>
{|width="40%" align="right" cellpadding="10"
|- valign="top"
|-
|
[[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'''<ul><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></ul>
::Leave the Root account '''disabled''' (ie do not set a password)
<br>
::'''INSTALLATION DESTINATION:'''
::*From the installation summary screen, click '''Installation Destination'''.
::*In the installation destination screen, select the destination option: '''I will configure partitioningCustom''' and then click '''Done'''.
::*The manual partitioning screen should appear.
::*If you have used your hard disk for previous Linux (CentOS) distributions, you should remove them. Click on the distribution, and for each partition, select the partition and click the remove button (minus sign) and confirm deletion.
::Remember that the sizes are recorded in MB (eg. 30 GB = 30000 MB) and you should multiply GB by a factor of 1024 to get the correct size. (eg. '''30 GB x 1024 = 30720 MB''')<br><br>
<ol><li value="5">We will now create our partitions. '''Click on the add button (plus) sign'''.<br></li>
{|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.