Lab 1: Ubuntu Linux

20 points

This lab serves as an introduction to Ubuntu Linux system administration. In it you will perform several small tasks that will help you gain familiarity with Linux. You'll also set up an Apache web server on a virtual machine and create a basic web page. You'll use this server throughout this semester.


  1. For this semester, you'll be doing your lab and project work on a virtual machine. You can access this VM via ssh from any of the machines in this lab or elsewhere on campus, or even from off campus via cs-ssh if you set up your public and private ssh keys according to these instructions.

    The domain name of your VM is given on the projects web page. You'll be accessing it through a text-based terminal program, ssh, and, eventually, a web browser.

    Log into one of the systems lab machines in Linux and start a terminal window. From there, log into your VM with ssh with the username mradmin and the password given on the whiteboard. You can use a command such as
    ssh mradmin@[yourID]

  2. Type useradd -h to get a summary of the use of the useradd command. Create a login for yourself. Use the first part of your Calvin email address as your login name. Include options that tell the useradd program to create a home directory for you, to add your user to the "sudo" group so you will be able to use sudo, and to use the /bin/bash shell.

    Note that useradd is a privileged command and you won't be able to run it without special permissions. There are a couple of options: logging in as root or giving yourself root privileges temporarily. To do the latter, prefix your command with sudo. You'll have to type in the password for the mradmin user again.

  3. To verify that you have the command right, click here for the answer.

  4. Set a password for the account you created with sudo passwd [yourlogin]. Log out of your VM and log in again with your normal user name to the account you just created.
  5. Make sure you are familiar with basic Linux commands cd, pwd, ls, cp, mv, rm, mkdir, rmdir, man, more, chmod, sudo. Try the ones you are unfamiliar with in the terminal window and make sure you know what each one does.
  6. You may have received a notice that security updates are available. If you value the security of your system, it's important to keep up to date with security updates. Figure out how to upgrade all packages to the latest versions with a couple of apt-get commands, and issue those commands. Answers:
  7. We'll be using the apache2 web server this semester. Its configuration files are located in /etc/apache2. Scan through the /etc/apache2 directory to familiarize yourself with the organization of the directory and configuration options. (Use more to view the contents of config files.)

    Editing configuration files risks making the system unusable--and if you don't remember the changes you may not be able to undo them. It is good practice to keep all versions of files so you can undo changes. We'll use git for this purpose. For now, we'll set up a git repository for the /etc/apache2 directory and create a backup of all the files. As root, first use the apt-get command to install the package named git.
    apt-get install git
    Then initialize a git repository in the /etc/apache2 directory and copy all files into it with the commands
    cd /etc/apache2
    git init -m "Initial commit of clean system"

    Each time you make changes to your apache config, once they are working correctly, you should change into the /etc/apache2 directory and perform the following commands:
    git add *
    git commit -m "message describing the change"

  8. Configure apache to handle User Directories, so that a URL like gets files from the public_html folder in zzz99's home directory, /home/zzz99/public_html. To do so you should enable the userdir module with the a2enmod command. For instructions on how to do this, you can search for a2enmod on this Ubuntu Apache2 tutorial.

    Any time you make configuration changes to the web server, you have to restart it before they will take effect. You can start, stop, and restart services the "service" command. To restart the web server type sudo service apache2 restart.

  9. For the next item, you'll need to use a text editor. vi and emacs are popular, but they take time to learn. You may use one of those editors for this course, but if you would like to use an easier one, 'nano' is a good option, but you'll need to install it.

    Software packages are installed in linux with "apt" commands ("advanced packaging tool"). You can install nano by typing
    sudo apt-get install nano

  10. Set the server's default character set to UTF-8. (Hint: there is a config file you can edit in the /etc/apache2/conf-enabled directory. You'll need to uncomment a line. Use nano or another familiar text editor to edit the file.)
  11. Any time you make configuration changes to the web server, you have to restart it before they will take effect. You can start, stop, and restart services with the scripts in the directory /etc/init.d. To restart the web server type sudo service apache2 restart.

  12. Create a directory public_html in your home directory and make sure it has world Read and eXecute permissions. Use cd to move into that directory.
  13. Create a lab1 directory in the public_html directory. Make sure all directories in public_html have world read an eXecute permissions. cd into the lab1 directory. Use the text editor nano (or vim) to create a simple web page containing a level 1 heading (<h1> element), an unordered list (<ol> <li>) of your three favorite movies, and a link to the IMDB page for each movie. Below, add a paragraph (<p) of info and an image relating to one of the movies. Save the file with the name lab1.html. Make sure it has world read permission.
  14. Test that the web page you created is visible on the web by visiting the projects page and clicking on the Home link by your name. Then click on lab1 and lab1.html. Your web page should appear. (If it doesn't, I won't be able to grade your lab.)

Turn In

I'll check that your web page is visible on the web. Also, you should email me ( the following things: