CMSC 104, Section 0501
Spring 2002
Laboratory Exercise 2
Objectives
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
We will learn how to do this together. To keep this procedure orderly, please pay close attention and try not to "experiment" with the software while I am talking.
You could also print these slides directly from the Powerpoint software. The print options are the same.
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
Mail News bin
(There may be additional files and subdirectories.)
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.
4. Look at the contents of the current directory. It should contain just the "sam.txt" file.
5. Display the contents of "sam.txt" on the monitor (cat sam.txt OR more sam.txt).
6. Move back to your home directory. Verify that you are there.
7. List the contents of the "Myfiles" directory. It should contain only "sam.txt".
8. Create another subdirectory under your home directory 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".
9. 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,
10. Move "sam.txt" from the "Morefiles" directory to your current (home) directory
( mv Morefiles/sam.txt . ). (Don't forget the period!)
11. Delete the "Morefiles" subdirectory.
12. Delete "sam.txt".
Be sure to logout completely when you have finished.