Lab 2 mnjk: Difference between revisions

From ITCwiki
Jump to navigation Jump to search
 
(54 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Introduction=
=Introduction=
'''''[https://www.youtube.com/watch?v=dQw4w9WgXcQ Watch the video introduction]'''''
In this lab you will perform the following tasks:
In this lab you will perform the following tasks:
*Installing the ''links'' web browser
*Installing the ''links'' web browser
Line 12: Line 10:
*Installing [https://www.python.org/ Python] and its dependencies
*Installing [https://www.python.org/ Python] and its dependencies


This lab assumes that you know the IP address of your Linux system and are connected to the ITCnet VPN network. If you need help with these steps please see a previous lab.
This lab assumes that you know the IP address of your Linux system and are connected to the ITCnet VPN network. If you need help with these steps please see [[ITC_VPN_Instructions | the VPN instructions]] and [[Lab_1_mnjk#Installing_sudo_and_checking_your_IP_address | the previous lab]].


You will use the following commands:
You will be introduced to the following commands:
*'''[https://linux.die.net/man/1/ls ls]'''
*'''[https://linux.die.net/man/1/ls ls]'''
*'''[https://linux.die.net/man/1/cd cd]'''
*'''[https://linux.die.net/man/1/cd cd]'''
Line 20: Line 18:
*'''[http://linux.die.net/man/1/mv mv]'''
*'''[http://linux.die.net/man/1/mv mv]'''
*'''[https://linux.die.net/man/1/man man]'''
*'''[https://linux.die.net/man/1/man man]'''
*'''[http://linux.die.net/man/8/sudo sudo]'''
*'''[http://linux.die.net/man/8/apt apt]'''
*'''[http://linux.die.net/man/1/links links]'''
*'''[http://linux.die.net/man/1/links links]'''
*'''[http://linux.die.net/man/1/mkdir mkdir]'''
*'''[http://linux.die.net/man/1/mkdir mkdir]'''
*'''[http://linux.die.net/man/1/pwd pwd]'''
*'''[http://linux.die.net/man/1/pwd pwd]'''
*'''[http://linux.die.net/man/1/ls ls]'''
*'''[http://linux.die.net/man/1/rm rm]'''
*'''[http://linux.die.net/man/1/rm rm]'''
*'''[http://linux.die.net/man/1/rmdir rmdir]'''
*'''[http://linux.die.net/man/1/rmdir rmdir]'''
*'''[http://linux.die.net/man/1/tar tar]'''
*'''[http://linux.die.net/man/1/tar tar]'''


=Preliminaries=
=Lab Procedure=
==Preliminaries==
# Ensure your VM is powered on in Netlab
# Ensure your VM is powered on in Netlab
#:''Note: you should have shut it down at the end of the last lab  
#:''NOTE: you should have shut it down at the end of the last lab, but you will leave it on from now on.
#:''Note: you will need to make a reservation in Netlab to power on your VM.
#:''NOTE: you will need to make a reservation in Netlab to power on your VM.
# Make sure you have the current IP address of your Linux system
# Make sure you have the current IP address of your Linux system
#: If your Linux VM has been powered off for some time since you checked the IP address in a previous lab you may have received a new IP address, so be sure to check your IP address again and use that IP address in this lab.  
#: If your Linux VM has been powered off for some time since you checked the IP address in a previous lab you may have received a new IP address, so be sure to check your IP address again and use that IP address in this lab.  
# Open an SSH console to your Linux system using the [https://www.putty.org/ PuTTY] software
# Open an SSH console to your Linux system using the [https://www.putty.org/ PuTTY] software
#: [[File:Lab2_putty.png|250px]]
#: [[File:Lab2_putty.png |link=https://wiki.ihitc.net/mediawiki/images/6/6f/Lab2_putty.png|500px]]
#: [[Media:Lab2_putty.png | Click for larger image]]
# Log in with your standard user account
# Log in with your standard user account
#: From this point on we will be working only through an SSH connection to the server so unless you have a problem with network access to your VM, or you need to power it on again you should not need to make Netlab reservations or use the Netlab interface for quite some time.
#: From this point on we will be working only through an SSH connection to the server so unless you have a problem with network access to your VM, or you need to power it on again you should not need to make Netlab reservations or use the Netlab interface for quite some time.


=Install the links web browser package=
==Install the Links Web Browser Package==
'''''[https://www.youtube.com/watch?v=2Ikzy23WuqQ&feature=youtu.be Video Tutorial: Installing the Links Web Browser]'''''
'''''[https://www.youtube.com/watch?v=2Ikzy23WuqQ&feature=youtu.be Video Tutorial - Installing the Links Web Browser]'''''
<ol>
<ol>
<li> Update your package lists using the following command:
<li> Update your package lists using the following command:</li>
<pre>sudo apt update</li>
<code>sudo apt update</code>
<ul> Because software installation and updates need to be done as an administrator we need to put '''sudo''' in front of these commands. You will likely need to enter your password again unless you've recently used sudo for something else and your session has not timed out yet.</ul>
: Because software installation and updates need to be done as an administrator we need to put '''sudo''' in front of these commands. You will likely need to enter your password again unless you've recently used sudo for something else and your session has not timed out yet.
<li> Search for a description of the ''links'' package using the following '''apt''' command to search for packages with links in the package name.
<li> Search for a description of the ''links'' package using the following '''apt''' command to search for packages with links in the package name.</li>
<pre> apt search --names-only links</li>
<code> apt search --names-only links</code>
<ul> ''TIP: You could further restrict your search using regular expressions instead of just searching for "links" such as '''apt search --names-only ^links''' which will only search for packages that ''start'' with the word links. You can learn more about regular expressions at [https://regexone.com RegexOne] and [https://www.regular-expressions.info Regular-Expressions.info] among many other places. These are frequently used in system administration and programming so it's worth your while to get at least a basic understanding of them.''</ul>
<ul> ''TIP: You could further restrict your search using regular expressions instead of just searching for "links" such as '''apt search --names-only ^links''' which will only search for packages that ''start'' with the word links. You can learn more about regular expressions at [https://regexone.com RegexOne] and [https://www.regular-expressions.info Regular-Expressions.info] among many other places. These are frequently used in system administration and programming so it's worth your while to get at least a basic understanding of them.''</ul>
<ul> ''TIP: You can also expand your search to include searching the full package descriptions instead of just the names like '''apt search links''' which returns many more results.''</ul>
<ul> ''TIP: You can also expand your search to include searching the full package descriptions instead of just the names like '''apt search links''' which returns many more results.''</ul>
<li> Check the details of the ''links'' software package using the following command:
<li> Check the details of the ''links'' software package using the following command: </li>
<pre>apt show links</li>
<code>apt show links</code>
<li> Install the ''links'' web browser package using the following aptitude command:  
<li> Install the ''links'' web browser package using the following aptitude command: </li>
<pre>sudo apt install links</li>
<code>sudo apt install links</code>
<li> Run the links program using the following command:
<li> Run the links program using the following command:</li>
<pre>links</li>
<code>links</code>
<ul> [[File:Links.png|250px]]</ul>
<ul> [[File:Links.png|link=https://wiki.ihitc.net/mediawiki/images/6/6e/Links.png|500px]]</ul>
<ul> [[Media:Links.png | Click for Larger Image]]</ul>
<li> Try browsing to a website such as ''www.google.com'' or ''www.debian.org''. </li>
<li> Try browsing to a website such as ''www.google.com'' or ''www.debian.org''. </li>
<ul> ''Hint: Press CTRL-G lets you enter a URL.''</ul>
<ul> ''Hint: Pressing CTRL-G lets you enter a URL. Alternatively, you can enter a URL from the command line such as '''links google.com'''''</ul>
<ul> ''Hint: Press ALT-F to get a menu bar to appear on your screen which you can then go through using arrow keys.''</ul>
<ul> ''Hint: Press ALT-F to get a menu bar to appear on your screen which you can then go through using arrow keys.''</ul>
<li> Press the letter "q" on your keyboard to quit links.</li>
<li> Press the letter "q" on your keyboard to quit links.</li>
Line 66: Line 64:
There are many other text-based browsers to choose from.  Some of these are more recent and have advanced features like handling SSL and cookies better.  If you are interested check out [http://w3m.sourceforge.net/ w3m] or [https://lynx.invisible-island.net/ lynx]
There are many other text-based browsers to choose from.  Some of these are more recent and have advanced features like handling SSL and cookies better.  If you are interested check out [http://w3m.sourceforge.net/ w3m] or [https://lynx.invisible-island.net/ lynx]


=Basic File Management and Navigation=
==Basic File Management and Navigation==
'''''[https://www.youtube.com/watch?v=v0rm7Iab624&feature=youtu.be Video Tutorial: Basic File Management and Navigation]'''''
'''''[https://www.youtube.com/watch?v=v0rm7Iab624&feature=youtu.be Video Tutorial - Basic File Management and Navigation]'''''
<ol>
<ol>
<li> Use the links web browser to open the page ''http://www.franske.com/shakespeare.tar.gz'' </li>
<li> Use the links web browser to open the page ''http://www.franske.com/shakespeare.tar.gz'' </li>
<li> Download the ''shakespeare.tar.gz'' file from that page. </li>
<li> Download the ''shakespeare.tar.gz'' file from that page. </li>
<li> Exit the links browser and verify the file has downloaded into your current directory with the following command:
<li> Exit the links browser and verify the file has downloaded into your current directory with the following command:</li>
<pre>ls -al</li>
<code>ls -al</code>
<ul> This command lists the files in the current directory.</ul>
<ul> This command lists the files in the current directory.</ul>
<li> Create a new directory called ''sample-files'' using the following command:
<li> Create a new directory called ''sample-files'' using the following command:</li>
<pre>mkdir sample-files</li>
<code>mkdir sample-files</code>
<li> Copy the ''shakespeare.tar.gz'' file from the current directory into the ''sample-files'' directory using:
<li> Copy the ''shakespeare.tar.gz'' file from the current directory into the ''sample-files'' directory using:</li>
<pre>cp shakespeare.tar.gz sample-files/ </li>
<code>cp shakespeare.tar.gz sample-files/ </code>
<ul> Note the / on the end of the command which indicates we want to place the file ''into'' a subdirectory and not make a new copy of the file in the same directory but with a different name. Pay attention to case, Linux is a case sensitive operating system. You can actually have two different files in the same directory, one called ''Shakespeare.tar.gz'' and one called ''shakespeare.tar.gz''</ul>
<ul> Note the / on the end of the command which indicates we want to place the file ''into'' a subdirectory and not make a new copy of the file in the same directory but with a different name. Pay attention to case, Linux is a case sensitive operating system. You can actually have two different files in the same directory, one called ''Shakespeare.tar.gz'' and one called ''shakespeare.tar.gz''</ul>
<li> Change your current directory to the ''sample-files'' directory using:  
<li> Change your current directory to the ''sample-files'' directory using: </li>
<pre>cd sample-files</li>
<code>cd sample-files</code>
<li>verify your directory change using the  print working directory command:
<li>verify your directory change using the  print working directory command:</li>
<pre>pwd</li>
<code>pwd</code>
<li>Verify the file has been copied by using the following command inside the ''sample-files'' directory:
<li>Verify the file has been copied by using the following command inside the ''sample-files'' directory:</li>
<pre>ls -al</li>  
<code>ls -al</code>  
<li> Delete (remove) the file from the current directory by using:
<li> Delete (remove) the file from the current directory by using:</li>
<pre> rm shakespeare.tar.gz</li>
<code> rm shakespeare.tar.gz</code>
<li>Change your directory back to your user's home directory (one level above the subdirectory you're currently in. </li>
<li>Change your directory back to your user's home directory (one level above the subdirectory you're currently in. </li>
<ul> There are many ways to do this but a common shortcut to move one directory up in the tree is to use the ".." shortcut which means one directory above the current directory so '''cd ..''' will change your working directory up one level.</ul>
<ul> There are many ways to do this but a common shortcut to move one directory up in the tree is to use the ".." shortcut which means one directory above the current directory so '''cd ..''' will change your working directory up one level.</ul>
<ul> This time we want to move the ''shakespeare.tar.gz'' file into the ''sample-files'' directory instead of copying it. </ul>
<ul> This time we want to move the ''shakespeare.tar.gz'' file into the ''sample-files'' directory instead of copying it. </ul>
<li>Use the following command to do this:
<li>Use the following command to do this:</li>
<pre>mv shakespeare.tar.gz sample-files/</li>
<code>mv shakespeare.tar.gz sample-files/</code>
<ul> Again, note the / on the end of sample-files/ indicating we want to put it in a ''directory'' named ''sample-files'' instead of renaming ''shakespeare.tar.gz'' to a ''file'' called ''sample-files''.</ul>
<ul> Again, note the / on the end of sample-files/ indicating we want to put it in a ''directory'' named ''sample-files'' instead of renaming ''shakespeare.tar.gz'' to a ''file'' called ''sample-files''.</ul>
<li> Verify the ''shakespeare.tar.gz'' file is no longer in your current directory then change your working directory to ''sample-files'' again and verify that the file has been moved there.</li>
<li> Verify the ''shakespeare.tar.gz'' file is no longer in your current directory then change your working directory to ''sample-files'' again and verify that the file has been moved there.</li>
Line 103: Line 101:
<li> Move up one directory (back to the ''sample-files'' directory). </li>
<li> Move up one directory (back to the ''sample-files'' directory). </li>
<ul> Let's say we want to remove the entire Shakespeare directory now. </ul>
<ul> Let's say we want to remove the entire Shakespeare directory now. </ul>
<li> Try using the following command to do that:
<li> Try using the following command to do that: </li>
<pre> rm</li>
<code> rm Shakespeare</code>
<ul> The '''rm''' command will give you an error because it is designed for removing files, not directories. To remove directories you can use the '''rmdir''' command such as '''rmdir Shakespeare''' but this will also give you an error. </ul>
<ul> The '''rm''' command will give you an error because it is designed for removing files, not directories. To remove directories you can use the '''rmdir''' command such as '''rmdir Shakespeare''' but this will also give you an error. </ul>
<li> Try it!
<li> Try it! </li>
<pre> rmdir Shakespeare </li>
<code> rmdir Shakespeare </code>
<ul> The '''rmdir''' command requires that a directory be empty before it can be removed. You now have a choice, you could go back into the directory and clear it out, one file at a time using the rm command. Or you could speed things up by removing all the files in it at once using the '''rm *''' command, which includes a special character, called a wildcard, which stands for all files in the directory. This would work but it still requires a second step and if there were even more levels of directories inside the one you wanted to remove you would have to go through all of them as well. Luckily, Linux has a powerful (but obviously dangerous) command the "recursive remove" command which removes a directory as well as all of the files and subdirectories it contains. You must be careful with this command because, used incorrectly, you could obviously delete everything on your hard drive with a single command. We want to remove the Shakespeare directory and everything it contains so we can use the '''rm -r Shakespeare''' command. </ul>
<ul> The '''rmdir''' command requires that a directory be empty before it can be removed. You now have a choice, you could go back into the directory and clear it out, one file at a time using the rm command. Or you could speed things up by removing all the files in it at once using the '''rm *''' command, which includes a special character, called a wildcard, which stands for all files in the directory. This would work but it still requires a second step and if there were even more levels of directories inside the one you wanted to remove you would have to go through all of them as well. Luckily, Linux has a powerful (but obviously dangerous) command the "recursive remove" command which removes a directory as well as all of the files and subdirectories it contains. You must be careful with this command because, used incorrectly, you could obviously delete everything on your hard drive with a single command. We want to remove the Shakespeare directory and everything it contains so we can use the '''rm -r Shakespeare''' command. </ul>
<li> Do this and then verify the directory has been removed.</li>
<li> Do this and then verify the directory has been removed.</li>
<li> Navigate back to your user's home directory before continuing.</li></ol>
<li> Navigate back to your user's home directory before continuing.</li></ol>


=Install the Apache 2 Webserver=
==Install the Apache 2 Webserver==
'''''[https://www.youtube.com/watch?v=56iOrpFbHOM&feature=youtu.be Video Tutorial: Installing Apache 2]
'''''[https://www.youtube.com/watch?v=56iOrpFbHOM&feature=youtu.be Video Tutorial - Installing Apache 2]
<ol><li> On your HOST system open a web browser and try browsing to the IP address of your Linux system. </li>
<ol><li> On your HOST system open a web browser and try browsing to the IP address of your Linux system. </li>
<ul> You should get some kind of server unreachable error because there is currently no webserver running on your system. </ul>
<ul> You should get some kind of server unreachable error because there is currently no webserver running on your system. </ul>
Line 122: Line 120:
<li> Once the installation process for Apache 2 is complete you should be able to go back to your host system and try visiting the IP address of your Linux system again or reloading the page. </li>
<li> Once the installation process for Apache 2 is complete you should be able to go back to your host system and try visiting the IP address of your Linux system again or reloading the page. </li>
<ul> You should now see a basic welcome page which indicates you have a webserver up and running on your Linux system. Obviously we haven't done anything exciting with the page yet or setup much security but it really is that simple to turn a Linux system into a basic webserver.</ul>
<ul> You should now see a basic welcome page which indicates you have a webserver up and running on your Linux system. Obviously we haven't done anything exciting with the page yet or setup much security but it really is that simple to turn a Linux system into a basic webserver.</ul>
<ul> [[File:Apache2.png|250px]]</ul></ol>
<ul> [[File:Lab2_apache2.png|link=https://wiki.ihitc.net/mediawiki/images/b/bc/Lab2_apache2.png|500px]]</ul>
<ul> [[Media:Lab2_apache2.png | Click for Larger Image]]</ul>
</ol>


=Install Python=
''NOTE: You can leave your VM running from this point on''
In order to check your work in the labs of this course you will need to have an application called [https://www.python.org/ Python] installed on your Linux system.
<ol>
<li> Download ''python3.6'' using '''apt'''</li>
<li> When prompted type Y to install the app and its dependencies</li>
<ul>This may take a while.</ul>
<li>When prompted to specify the name of the host where the TANGO database server is running, just select ok.</li>
<ul> [[File:Python_tango.png|250px]]</ul>
<li> Run the following command to verify that python version 3.6 is installed.
<pre>python3 --version</li>
<ul> [[File:Python_version.png|250px]]</ul>
<ul> ''Note: You can leave your VM running from this point on''</ul>
</ol>


=Checking your Work=
=Checking Your Work=
<ol><li> Return to your home directory and run:
<ol><li> Return to your home directory and run:</li>
<pre>ls -al</li>
<code>ls -al</code>
<ul> If you see the ''shakespeare.tar.gz'' file you haven't followed all the directions.</ul>
<ul> If you see the ''shakespeare.tar.gz'' file you haven't followed all the directions.</ul>
<li> List the files in the sample-files directory:</li>
<li> List the files in the sample-files directory:</li>
<ul> If you only see the ''shakespeare.tar.gz'' file you have successfully completed that section of the lab.</ul>
<ul> If you only see the ''shakespeare.tar.gz'' file you have successfully completed that section of the lab.</ul>
<li> Run the following command:
<li> Run the following command:</li>
<pre> links</li>
<code> links</code>
<ul> If the Links browser opens you have successfully installed it.</ul>
<ul> If the Links browser opens you have successfully installed it.</ul>
<li> Navigate to your ip address using the Links browser; does the website look like this?</li>
<li> Navigate to your ip address using the Links browser; does the website look like this?</li>
<ul> [[File:links_apache2.png|250px]]</ul>
<ul>[[file:Links_apache2.png | link= https://wiki.ihitc.net/mediawiki/images/1/12/Links_apache2.png | 500px]]</ul>
<li> Run the following command; does the output look like this?
<ul>[[media:Links_apache2.png| Click for Larger Image]]</ul>
<pre>python3 --version</li>
 
<ul> [[File:python_version.png|250px]]</ul>
<li> Run the following command; does the output look like this?</li>
<code  background-color: #f1f1f1>python3 --version</code>
<ul> [[File:Python_version.png|link=https://wiki.ihitc.net/mediawiki/images/7/70/Python_version.png|500px]]</ul>
<ul> [[Media:Python_version.png | Click for Larger Image]]</ul>
<ul> If your results match the screenshots, you have successfully completed the lab! </ul>
<ul> If your results match the screenshots, you have successfully completed the lab! </ul>
<br>
<br>
<br>
<br>
<li>[https://www.youtube.com/watch?v=dQw4w9WgXcQ Run this script to automatically check your lab]</li>
<li> Automatically check your results by running this command:</li>
<code><nowiki>
curl https://raw.githubusercontent.com/mnjk-inver/Linux-2480-Rebuild/main/lab_02_test.py | python3
</nowiki></code>
<br><br>
=Web App=
 
You can check your progress on any of the labs in the ITC-2480 course from a webapp from this link:  <br>
[http://webcheck.itc2480.campus.ihitc.net webcheck.itc2480.campus.ihitc.net]<br>
You must be logged into the campus VPN to use this application.
</ol>
</ol>

Latest revision as of 01:13, 20 April 2021

Introduction

In this lab you will perform the following tasks:

  • Installing the links web browser
  • Downloading a compressed file
  • Creating a directory
  • Copying and moving files
  • Extracting a .tar.tz "tarball" file
  • Removing files and directories
  • Installing the Apache webserver
  • Installing Python and its dependencies

This lab assumes that you know the IP address of your Linux system and are connected to the ITCnet VPN network. If you need help with these steps please see the VPN instructions and the previous lab.

You will be introduced to the following commands:

Lab Procedure

Preliminaries

  1. Ensure your VM is powered on in Netlab
    NOTE: you should have shut it down at the end of the last lab, but you will leave it on from now on.
    NOTE: you will need to make a reservation in Netlab to power on your VM.
  2. Make sure you have the current IP address of your Linux system
    If your Linux VM has been powered off for some time since you checked the IP address in a previous lab you may have received a new IP address, so be sure to check your IP address again and use that IP address in this lab.
  3. Open an SSH console to your Linux system using the PuTTY software
    Lab2 putty.png
    Click for larger image
  4. Log in with your standard user account
    From this point on we will be working only through an SSH connection to the server so unless you have a problem with network access to your VM, or you need to power it on again you should not need to make Netlab reservations or use the Netlab interface for quite some time.

Install the Links Web Browser Package

Video Tutorial - Installing the Links Web Browser

  1. Update your package lists using the following command:
  2. sudo apt update
    Because software installation and updates need to be done as an administrator we need to put sudo in front of these commands. You will likely need to enter your password again unless you've recently used sudo for something else and your session has not timed out yet.
  3. Search for a description of the links package using the following apt command to search for packages with links in the package name.
  4. apt search --names-only links
      TIP: You could further restrict your search using regular expressions instead of just searching for "links" such as apt search --names-only ^links which will only search for packages that start with the word links. You can learn more about regular expressions at RegexOne and Regular-Expressions.info among many other places. These are frequently used in system administration and programming so it's worth your while to get at least a basic understanding of them.
      TIP: You can also expand your search to include searching the full package descriptions instead of just the names like apt search links which returns many more results.
  5. Check the details of the links software package using the following command:
  6. apt show links
  7. Install the links web browser package using the following aptitude command:
  8. sudo apt install links
  9. Run the links program using the following command:
  10. links
      Links.png
  11. Try browsing to a website such as www.google.com or www.debian.org.
    • Hint: Pressing CTRL-G lets you enter a URL. Alternatively, you can enter a URL from the command line such as links google.com
      Hint: Press ALT-F to get a menu bar to appear on your screen which you can then go through using arrow keys.
  12. Press the letter "q" on your keyboard to quit links.


There are many other text-based browsers to choose from. Some of these are more recent and have advanced features like handling SSL and cookies better. If you are interested check out w3m or lynx

Basic File Management and Navigation

Video Tutorial - Basic File Management and Navigation

  1. Use the links web browser to open the page http://www.franske.com/shakespeare.tar.gz
  2. Download the shakespeare.tar.gz file from that page.
  3. Exit the links browser and verify the file has downloaded into your current directory with the following command:
  4. ls -al
      This command lists the files in the current directory.
  5. Create a new directory called sample-files using the following command:
  6. mkdir sample-files
  7. Copy the shakespeare.tar.gz file from the current directory into the sample-files directory using:
  8. cp shakespeare.tar.gz sample-files/
      Note the / on the end of the command which indicates we want to place the file into a subdirectory and not make a new copy of the file in the same directory but with a different name. Pay attention to case, Linux is a case sensitive operating system. You can actually have two different files in the same directory, one called Shakespeare.tar.gz and one called shakespeare.tar.gz
  9. Change your current directory to the sample-files directory using:
  10. cd sample-files
  11. verify your directory change using the print working directory command:
  12. pwd
  13. Verify the file has been copied by using the following command inside the sample-files directory:
  14. ls -al
  15. Delete (remove) the file from the current directory by using:
  16. rm shakespeare.tar.gz
  17. Change your directory back to your user's home directory (one level above the subdirectory you're currently in.
    • There are many ways to do this but a common shortcut to move one directory up in the tree is to use the ".." shortcut which means one directory above the current directory so cd .. will change your working directory up one level.
      This time we want to move the shakespeare.tar.gz file into the sample-files directory instead of copying it.
  18. Use the following command to do this:
  19. mv shakespeare.tar.gz sample-files/
      Again, note the / on the end of sample-files/ indicating we want to put it in a directory named sample-files instead of renaming shakespeare.tar.gz to a file called sample-files.
  20. Verify the shakespeare.tar.gz file is no longer in your current directory then change your working directory to sample-files again and verify that the file has been moved there.
    • The .tar.gz type files are sometimes called a "tarball" and they are a common way to distribute files on *NIX (UNIX/Linux/BSD/POSIX) based systems. These files really have two parts. The first is a TAR file which is a way to pack multiple files and directories into a single file for archival an distribution purposes but does not compress the file in any way, the size will be essentially the same as if you added together all of the files it contains. After the files are put into a TAR file they can be compressed with the gzip program so we add the .gz extension to the filename to indicate this TAR file has been compressed. Other compression programs such as bzip2 can also be used, in that case it would be a .tar.bz2 file. Because TAR files are so frequently gzipped to compress them the command to compress or uncompress a file as been added to the TAR program itself so we don't need to go through two steps. In this case we can uncompress and extract the files using the tar -zxf shakespeare.tar.gz command or to see the list of files as they are extracted we can add the -v argument to the command to make the output verbose tar -zxvf shakespeare.tar.gz
  21. Run the command to extract and uncompress the file.
  22. Verify it by listing the directory contents.
    • You should see a new subdirectory, it's common and good practice to always include the files in a TAR in their own subdirectory so that when they are extracted they don't clutter the current working directory.
  23. Enter the new subdirectory and list the contents to verify the extraction, you should see several files.
  24. Try removing one of the files that was extracted.
    • You might encounter an error if the filename includes a space. Although spaces are allowed in filenames on Linux, it's not recommended because you will need to either quote or escape filenames in some way in order to work with the files. For example if you wanted to remove a file called a file with spaces.txt you would either need to enter the command as rm "a file with spaces.txt" (with the quotes) or as rm a\ file\ with\ spaces.txt where the backslash character is used to "escape" the special characters in the filename (in this case spaces, but other characters, like exclamation points, are special as well). Make sure you can remove a file with spaces in the name.
  25. Move up one directory (back to the sample-files directory).
    • Let's say we want to remove the entire Shakespeare directory now.
  26. Try using the following command to do that:
  27. rm Shakespeare
      The rm command will give you an error because it is designed for removing files, not directories. To remove directories you can use the rmdir command such as rmdir Shakespeare but this will also give you an error.
  28. Try it!
  29. rmdir Shakespeare
      The rmdir command requires that a directory be empty before it can be removed. You now have a choice, you could go back into the directory and clear it out, one file at a time using the rm command. Or you could speed things up by removing all the files in it at once using the rm * command, which includes a special character, called a wildcard, which stands for all files in the directory. This would work but it still requires a second step and if there were even more levels of directories inside the one you wanted to remove you would have to go through all of them as well. Luckily, Linux has a powerful (but obviously dangerous) command the "recursive remove" command which removes a directory as well as all of the files and subdirectories it contains. You must be careful with this command because, used incorrectly, you could obviously delete everything on your hard drive with a single command. We want to remove the Shakespeare directory and everything it contains so we can use the rm -r Shakespeare command.
  30. Do this and then verify the directory has been removed.
  31. Navigate back to your user's home directory before continuing.

Install the Apache 2 Webserver

Video Tutorial - Installing Apache 2

  1. On your HOST system open a web browser and try browsing to the IP address of your Linux system.
    • You should get some kind of server unreachable error because there is currently no webserver running on your system.
  2. Use the apt show command to review details of the apache2 package
    • Apache is one of the most popular webserver programs on the Internet.
  3. After reading through the information go ahead and install the apache2 package using apt install.
    • You'll notice this time, because it's a more complex program than links, you will be prompted to install several other packages that apache relies on to run, we call these packages "dependencies". One key advantage of using a "package manager" like apt, apt-get, or aptitude is that they automatically keep track of dependencies and install packages needed to make the one you're trying to install function properly.
  4. Once the installation process for Apache 2 is complete you should be able to go back to your host system and try visiting the IP address of your Linux system again or reloading the page.
    • You should now see a basic welcome page which indicates you have a webserver up and running on your Linux system. Obviously we haven't done anything exciting with the page yet or setup much security but it really is that simple to turn a Linux system into a basic webserver.
      Lab2 apache2.png

NOTE: You can leave your VM running from this point on

Checking Your Work

  1. Return to your home directory and run:
  2. ls -al
      If you see the shakespeare.tar.gz file you haven't followed all the directions.
  3. List the files in the sample-files directory:
    • If you only see the shakespeare.tar.gz file you have successfully completed that section of the lab.
  4. Run the following command:
  5. links
      If the Links browser opens you have successfully installed it.
  6. Navigate to your ip address using the Links browser; does the website look like this?
    • Links apache2.png
  7. Run the following command; does the output look like this?
  8. python3 --version
      Python version.png
      If your results match the screenshots, you have successfully completed the lab!



  9. Automatically check your results by running this command:
  10. curl https://raw.githubusercontent.com/mnjk-inver/Linux-2480-Rebuild/main/lab_02_test.py | python3

    Web App

    You can check your progress on any of the labs in the ITC-2480 course from a webapp from this link:
    webcheck.itc2480.campus.ihitc.net
    You must be logged into the campus VPN to use this application.