CMSC 121 - Introduction to UNIX - Fall 2004 - Final Exam

This exam is open book / open notes / open web.

True/False (1 pt. each)

With the text editor of your choice, create a file called "tf.txt". Answer the following questions 1 answer per line, with the problem number in front of the answer, like so...

1. T
2. F
3. T
4. F
...
  1. The 3 main parts of the UNIX operating system are the kernel, the shell and the built in utilities.
     
  2. Gnome is a Window Manager.
     
  3. KDE is an implementation of an X server.
     
  4. An X-server is what all clients speak to in order to have windows actually drawn onto the computer screen.
     
  5. The only method of sending email from UMBC is through Pine.
     
  6. AFS is the file system that is used here at UMBC to store and organize students files.
     
  7. The "ls -la" command will show you all files (including hidden) in a long listing format.
     
  8. You can suspend a program that is running in the foreground by ussing a Ctrl-C
     
  9. The "password" command is used to change your password on the GL system.
     
  10. SSH is basically a secure alternative to telnet.
     
  11. SCP has no advantages over FTP.
     
  12. To terminate a program that is running in the foregroung you type Ctrl-Z
     
  13. The "cwd" command is used to print out the current working directory.
     
  14. When you log on to the system you are placed in your root directory which is located at "/afs/umbc.edu/users/u/s/username/" (as always u and s are the first 2 letters of your user name, and username is your log on name).
     
  15. The "touch" command is used to create directories.
     
  16. The "chdir" command is used to change directories.
     
  17. The "mv" command is used to rename files and can also be used to move files from one directory to another.
     
  18. Linux and Windows typically use different file systems.
     
  19. Under Linux you can only use the Turbo C Shell (tcsh) and the Borne Again Shell (bash).
     
  20. The command "!!" executes the first command that you typed when you logged in.
     

You are now done writing to the file called "tf.txt". You can exit your editor, making sure that you save your changes.

Multiple Choice (1 pt. each)

With the text editor of your choice, create a file called "mult.txt". Answer the following questions 1 answer per line, with the problem number in front of the answer, like so...

1. A
2. B
3. C
4. D
...
  1. When you open a shell at UMBC you in you are in what directory by default?
    1. /afs/umbc.edu/users/username/
    2. /afs/umbc.edu/users/u/s/username/
    3. /home/username/
    4. /afs/umbc.edu/users/u/s/username/home/
     
  2. The "wc" command shows you what information about files?
    1. The number of characters in that file
    2. The number of lines in that file
    3. The number of words in that file
    4. All of the above
     
  3. The "which" command is used to do which of the following?
    1. The specific location of the command that you are using
    2. All locations of that command in your PATH
    3. Which users are logged onto a system
    4. None of the above
     
  4. What are the keystrokes to exit from Emacs?
    1. Ctrl-X Ctrl-S
    2. Ctrl-X Ctrl-C
    3. Ctrl-X
    4. Q
     
  5. What is the PATH?
    1. Is the course that is taken when navigating through directories
    2. Your home directory
    3. The location of all places to look for a command when you type a command at the shell
    4. None of the above
     
  6. What can I do with the command "xkill"?
    1. Terminate shell based programs
    2. Terminate X windows programs
    3. Terminate only jobs that were run in the background
    4. Terminate only jobs that were run in the foreground
     
  7. If executed the following command "ls proj*.c" what set of files would I expect to see?
    1. proj2.c project2.c
    2. proj1.c proj3.c proj5.c
    3. Both A and B
    4. Neither A not B
     
  8. The ampersand (&) is used for what?
    1. To run commands faster
    2. To run commands in the foreground
    3. To run commands in the background
    4. To run commands under X windows
     
  9. How can I launch Pine, so that it automatically comes up to the compose message screen with the recipients name already filled in.
    1. pine -i
    2. pine username@foo.com
    3. pine to:username@foo.com
    4. pine --compose username@foo.com
     
  10. Which is the correct syntax for setting up an alias under tcsh
    1. alias mem="quota -v";
    2. set alias mem "quota -v"
    3. $MEM = "quota -v"
    4. alias mem "quota -v"
     

You are now done writing to the file called "mult.txt". You can exit your editor, making sure that you save your changes.

Short Answer (2pts. each)

With the text editor of your choice, create a file called "short.txt". Answer the following questions, with the problem number in front of the answer, like so...

1. This is my answer to problem 1.
2. If I need to break my problem across
multiple lines that is fine.
3. Good Luck.
...
  1. We have gone over at least 5 ways to view files without opening them up in a text editor. Name 3 ways to view a files contents (some of the commands were used to view specific parts of a file, they are acceptable as well).
  2. What a command that is used to print out all of the users that are on the system?
     
  3. What are multiple desktops?
     
  4. List 3 ways to get into your HOME directory from any other directory on the system.
     
  5. Say you accidently deleted the file "/afs/umbc.edu/users/u/s/username/home/cmsc121/foo.c" but it was there for the last couple of days. Assuming that you are in your home directory tell me the command(s) that you would use to restore this file from where it is backed-up.
     
  6. Let's assume that this was the last command typed by a user...
    linux2 [5]# history
         1	11:58	cd
         2	11:58	ls
         3	11:58	gcc -Wall -ansi hello.c -o hello
         4	11:58	emacs hello.c
         5	11:59	history
    linux2 [6]# 
    
    Tell me two ways using a "!" character followed by whatever else to re-execute the command "gcc -Wall -ansi hello.c -o hello".
     
  7. If I am unsure what a specific command does, what command can I execute that will give me documentation about that command?
     
  8. What is a quota, and what is the command that is used to check and see how much of it you are using?
     
  9. Tell me what PID stands for and what that is. How can I tell what the PID is for a given command that is running?
     
  10. Explain to me what UNIX redirection is. What command would I would execute if I wanted to be able to capture a directory listing to a file called "listing.txt".
     

You are now done writing to the file called "short.txt". You can exit your editor, making sure that you save your changes.

Interactive (5pts. each)

Like on the last homework, we are going to capture this whole session to disk. To do this open a shell and make sure that you are in your home directory. If you have a file called "typescript" please either delete or rename the file. Type the command "script" to go ahead and begin logging the session. You will need to copy over some files from my public directory to get started. Do this with the following command: "cp -r /afs/umbc.edu/users/d/h/dhood2/pub/cmsc121/final .". Now you should be ready to get started on this last part...

  1. Change the current working directory to the newly copied over final directory. Do a long, human readable, listing that shows even hidden files.
     
  2. Issue the command that will find all copies of the file called "cmsc121.txt". Now issue the command that will find all copies of all files that are in the form "cmsc" followed by any combination of characters followed by ".txt".
     
  3. I now want you to locate all files that I put my name in as authoring. I was not consistent when I wrote my name as part of the text of that document, so you will want to search for any combination of lowercase or uppercase characters matching the name "dan"
     
  4. I want you to remove the directory called "dirA". There are files within this directory so you will have to deal with this. You can delete everything that is in that directory.
     
  5. There is a file called "cmsc201.txt" in the directory called "dirC". I want you to move that file from that directory into the directory called "dirB".
     
  6. I want you to issue the command that will take the file called "names" and sort the people in that file by name and output the results to a file called "sorted".
     
  7. I want you to issue that command that will list all of the users that are logged onto the system that you are, and take that output and search for where your name appears in that output. This should be done via a single command joined together with a special character that we talked about that will allow the output from one command to be used as the input to another.
     
  8. I want you to issue a command that will show the difference between the 2 files "foo.c" and the "foo.c" that is in the directory called "dirC".
     
  9. Issue a single command (using wild cards) that will remove all of the files that end in ".c", ".h" and ".txt"
     
  10. Issue the following command "(sleep 600)&". This runs a dummy command that does nothing for 600 seconds then exits. I want you to terminate this command by it's PID. I want you to issue the command that you can use to look it up, and then issue the command to actually terminate the command.
     

That's it you're done. Go ahead and type "exit" to stop logging your session.

Submitting

Now that all of the files that you will need to hand in are completed. I want you to go ahead and submit them by emailing them to me (dhood2@cs.umbc.edu) as a attachments. Be sure to submit all of the following files.

tf.txt, mult.txt, short.txt, typescript


Daniel J. Hood
Last modified: Thu Oct 14 16:56:20 EDT 2004