CMSC 104

Fall 2001

Laboratory Exercise

Objectives

To learn to print the class lecture slides using Internet Explorer
To practice using the basic UNIX/Linux commands
Note that there is nothing that you must turn in associated with this exercise. If you do not finish the exercise during the lab session, it is to your benefit to finish it later on your own.

 

Part I - Printing Class Lecture Slides

From today on, you will be responsible for printing your own copies of class lecture slides. We will learn how to do this together.I will be giving you instructions verbally. To keep this procedure orderly, please pay close attention and do not experiment with the software while I am talking.

Part II - Using Basic UNIX/Linux Commands

Commands you will use: pwd, ls, mkdir, cd, cat, more, rm, rmdir, mv
Follow the steps below in order. Notice that you are sometimes given the command to use in parentheses. As you move through the exercise, you are given fewer and fewer commands. It's time to think! Use your class notes as a reference. And make sure to take your time and really understand what you are doing.
Creating a Directory Hierarchy (Tree) To Use During the Semester

1. Log into your gl account.

2. Look at the name of your home directory (pwd).
3. Look at the contents of your home directory (ls). It should contain the following subdirectories:
Mail   News  bin
(There may be additional files and subdirectories.)
4. Look at the long contents of your home directory (ls -l). You should see the same subdirectories, but with more information about each.
5. Create a subdirectory called CS104 (mkdir CS104). Verify that it has been created by again looking at the contents of your home directory.
6. Move to the CS104 directory (cd CS104). Verify that your current directory is now indeed CS104.
7. Create eight new subdirectories, one for each of the eight projects that you will be doing in this class. Call them Project1, Project2, ... Project8. Verify that each of the subdirectories has been created.
8. Move your mybio.txt file from your home directory into the Project1 directory (mv ../mybio.txt Project1). Check to see that it is no longer in your home directory (ls ..). Now check to see that it is in the Project1 directory (ls Project1).
9. Move back to your home directory. Verify that your current directory is now indeed your home directory.

More Practice With Directory and File Commands

You should be back in your home directory. If you are not, move to it before beginning.
1. Create a subdirectory named Myfiles. Verify that the subdirectory exists.
2. Move to the Myfiles directory. Verify that you are there.
3. Use the pico editor to create a file called sam.txt. The contents of sam.txt should be as follows:
    I am Sam. Sam I am.
    Do you like green eggs and ham?
Save the file and exit pico.
 
9. Look at the contents of the current directory. It should contain just the sam.txt file.
10. Display the contents of sam.txt on the monitor (cat sam.txt OR more sam.txt).
11. Move back to your home directory. Verify that you are there.
12. List the contents of the Myfiles directory. It should contain only sam.txt.
13. Create another subdirectory called Morefiles. Verify that it exists.
    a. Copy the file sam.txt from Myfiles to Morefiles (cp Myfiles/sam.txt Morefiles).
    b. Look at the contents of the Morefiles subdirectory. It should now contain sam.txt.
14. Try to delete the Myfiles subdirectory (rmdir Myfiles). You will get a message that the directory is not empty. You must delete all files and subdirectories from a directory before deleting the directory itself. So,
    a. Delete sam.txt from Myfiles (rm Myfiles/sam.txt).
    b. Look at the contents of Myfiles to make sure that it is empty.
    c. Delete the Myfiles subdirectory (rmdir Myfiles).
    d. Look at the contents of your current (home) directory to make sure that Myfiles has been deleted.
15. Move sam.txt from the Morefiles directory to your current (home) directory
(mv Morefiles/sam.txt .). (Don?t forget the period!)
    a. Look at the contents of your home directory to be sure that sam.txt is there.
    b. Look at the contents of Morefiles to be sure that sam.txt is no longer there.
16. Delete the Morefiles subdirectory.
17. Delete sam.txt.
Be sure to logout completely when you have finished.