Changes

Jump to: navigation, search

OPS235 Lab 5 - CentOS6

265 bytes added, 12:15, 27 November 2019
no edit summary
[[Category:OPS235]] {{Admon/caution|Draft LabTHIS IS AN OLD VERSION OF THE LAB|'''This lab has NOT been released for regular distributionis an archived version. When the lab is ready to be released, Do not use this caution banner will disappearin your OPS235 course.'''}} 
=Archiving Files, Compiling Software Packages from Source, Managing Services=
[[Category:OPS235]][[Category:OPS235 Labs]]
*[http://linuxmanpages.com/man1/make.1.php make]
|
*[ service]
*[http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-services-chkconfig.html chkconfig]
Additional links to tutorials and HOWTOs:
* [http://www.centos.org/docs/2/rhl-gsg-en-7.2/s1-zip-tar.html archiving with tar, gzip, gunzip]
* [http://www.tuxfiles.org/linuxhelp/softinstall.html Compiling Software from Source Code]
* [[init vs systemd]]
* [https://wiki.debian.org/Debate/initsystem/upstart init vs systemd vs upstart]
* [https://www.centos.org/docs/5/html/5.2/Installation_Guide/s2-init-boot-shutdown-rl.html Runlevels]
==Archiving Files / Compiling Software from Source Code==
===Investigation 1: How do you create an archive file?===
{{Admon/note|Use fedora3centos3|Perform these steps in the '''fedora3centos3''' virtual machine.}}
#Boot up your '''fedora3centos3''' VM.
#Change your working directory to <code>/usr/share/doc/sudo*</code>
#Use the tar (tape archiver) command to create an archive file named <code>/tmp/archive1.tar</code>
===Investigation 2: How do you restore files from an archive?===
{{Admon/note|Remain in your fedora3 centos3 VM|Perform these steps in the '''fedora3centos3''' virtual machine.}}
#Create the directory <code>/tmp/extract1</code>
#Change to the <code>/tmp/extract1</code> directory.
'''Answer the Investigation 2 observations / questions in your lab log book.'''
 
===Investigation 3: How do you build software from source code?===
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 or rpm command, this method is useful if the application is NOT contained in regular software repositories...
{{Admon/note|Use fedora2centos2|Perform these steps in the '''fedora2centos2''' virtual machine.}}
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.
#Boot up your '''fedora2''' VM. <!-- corrected a couple typos Eric D.-->
# Issue the following command to install a basic set of development tools and libraries:<br /><code>yum groupinstall "Development Tools" "Development Libraries"</code>
<ul>
<li><code>make</code></li>
<li>Did the command work? Why? Use the <code>yum</code> command to install the package '''gcc'''. What do you think the package ''gcc'' does?</li>
</ul>
<li>Reissue the <code>make</code> command. Where you successful? What does <code>make</code> do?</li> <li>Issue the command as root: <code>yum list ncurses</code>. What do you see? Issue the command at root: <code>yum search ncurses</code>. What do you observe?</li> <li>In this case, you need to install the ncurses development libraries as well. Issue the following command as root: <code>yum install ncurses-devel.x86_64</code>. Now issue the command: <code>make</code></li>
<li>Some software distributed as source code can automatically install itself. Try this command:
<ul>
</li>
<li>Most but not all source code archives include the capability of installing themselves this way.</li>
<li>If the command <code>make install</code> does not work (how can you tell? What command did you learn from ULI101 to confirm that this command cannot be run from the command line?), copy the <code>nled</code> program manually:
<ul>
<li><code>cp nled /usr/local/bin</code></li>
</li>
<li>Test <code>nled</code> to make sure it works.</li>
<li>Why did copying the nled executable to /usr/local/bin allow the nled command to be run by name anywhere in the command prompt?</li>
</ol>
===Investigation 4: How do we Manage Runlevels?===
{{Admon/note|Use fedora2centos2 and centos3|Perform these steps in the '''fedora2''' both of these virtual machinemachines.}} The runlevel command is now deprecated in Fedora, and will likely be deprecated in RHEL/CentOS at some point as well, but for now this is what the industry is using.
The runlevel command is now deprecated in Fedora, and has been replaced by '''systemctl'''. The newer system called '''systemd''' is a newer method to help simplify controlling both runlevels (referred to as "targets" and system services (referred to as "services"). Refer to the tutorial [[init vs systemd]] for systemctl command usages and reference.
<ol>
<li>Issue the following Linux command:
<ul>
<li><code>systemctl list-units --type=targetrunlevel</code></li>
</ul>
</li>
<li>Note the target labelled graphicaldifference in output between centos2 and centos3. Now trace the chain of links starting at /etc/systemd/system/default.target - what's it ultimately pointing to?</li> <li>Issue the following commands to switch You can use the default mode (also known as target, formerly runlevel): <ul> <licode>init</code>rm command to change the current runlevel. See a list of runlevels [https:/etc/systemd/system/defaultwww.centos.target<org/code><docs/li> <li><code>ln -s 5/libhtml/systemd5.2/systemInstallation_Guide/multis2-userinit-boot-shutdown-rl.target /etc/systemd/system/defaulthtml here].targetUse the </code>man</licode> command to learn how to use the </ulcode> <li/code>Restart your fedora2 VMinit command. Use this command to change the current runlevel in centos2 to 3. What happened? What happensafter your reboot?</li> <li>Log into your regular user accountChange the default runlevel on centos2 to 3.What happens now after you reboot?</li>
<li>Issue the following Linux command:
<ul>
<li>What happens?</li>
<li>Log-off your graphical system. You should return to your shell prompt.</li>
<li>Issue Change the following commands: <ul> <li><code>rm /etc/systemd/system/defaultrunlevel for centos2 back to 5 and reboot to make sure it works.target</code></li> <li><code>ln -s /lib/systemd/system/graphical.target /etc/systemd/system/default.target</code></li> </ul> </li> <li>Reboot your fedora2 VM. What Happens?</li>
</ol>
=== Investigation 5: How do we Manage System Services? ===
{{Admon/note|Remain in your fedora2 centos2 VM|Perform these steps in the '''fedora2centos2''' virtual machine.}}
We have seen that maintaining unneeded '''packages can be a security risk''' due to the unnecessary increase in the complexity of your system. Similarly, it is also unnecessarily hazardous, and even more so, to leave unneeded services running. In this investigation, we will learn how to '''control services, and turn off those services that we think are not necessary to help reduce security risks'''.}}
<li>Issue the following Linux command:
<ul>
<li><code>systemctl listservice -units -status-type=serviceall</code></li>
</ul>
</li>
<li>Note the services that are currently running.</li>
<li>Refer to Use the tutorial ([[init vs systemd]] ) to learn how to use the systemctl <code>service</code> command to stop the service named '''iptables'''</li> <li>Issue the systemctl <code>service</code> command to verify that this service has stopped.</li> <li>If you reboot now - the iptables service will be turned back on. We don't want it on though, it causes students headaches. To turn it off permanently we need to disable the service. Refer to the tutorial ([[init vs systemd]] ) to learn how to use the systemctl chkconfig command to disable the service named ''': <code>chkconfig iptables'''off</code></li>
<li>Reboot and confirm that it's no longer running.</li>
</ol>
# Compressed files: <code>/tmp/archive1.tar.gz</code> and <code>/tmp/archive2.tgz</code>
#<code>nled</code> application is installed
#Lab5 notes how to use systemctl service/chkconfig commands
#VMs backed-up
#How do you build software from source code?
#Which is preferred: installing from an RPM file, or installing from source code? Why?
#How do you use <code>systemctlservice/init/chkconfig</code> to:#*list show/set current runlevel
#*list services
#*stop a service
#*Why is it important to stop certain services?
 {{Admon/important | Backup your work |Backup your disk images for fedora2 centos2 and fedora3 centos3 Virtual Machines.}}

Navigation menu