CMSC 121 - Introduction to UNIX - Fall 2004 - HW 3
Out: Saturday October 9th       Due: Thursday October 14th

This homework is an exercise in using more advanced unix commands.

In order for the whole assignment to be logged to a file, you will need to sit down and complete the whole thing from beginning to end without logging out. If you make mistakes or typos as you go, do not worry about it. Fix and re-issue the command.

I strongly recommend that you figure out what command and what arguments you are going to be typing for each step before you actually issue the command. This way you can test out the command before you actually sit down and log the entire assignment.

  1. Connect via SSH to linux.gl.umbc.edu. You will be doing this assignment via a SSH connection to one of the Linux servers. You may use the SSH client of your choice.
     
  2. Make sure that you are in you home directory.
     
  3. First type script at the command prompt. This will allow for the entire interaction that you have with the UNIX environment to be logged to a file called "typescript". You should see the message "Script started, file is typescript".
     
  4. Before we really get started, you will need to copy over a bunch of files and directories rooted at "/afs/umbc.edu/users/d/h/dhood2/pub/cmsc121/hw3/". I will supply you the command to do this. It is "cp -r /afs/umbc.edu/users/d/h/dhood2/pub/cmsc121/hw3/ ."
     
  5. Change directories into this hw3 directory.
     
  6. Hidden within the directory structure within this current directory are 2 files that I would like to find...
     
    1. Issue the command to locate the file called "foo" (not foo.c)
    2. Issue the command to locate the file called "bar" (not bar.c)
       
  7. Now issue the command to find all files that have the word "favorite" to start off the file name.
     
  8. You will notice a bunch of *.c and *.h source code files scattered across these directories. Two different programmers wrote all of these files. For this part of the exercise, you will find out which files were modified by who, using the command that searches the text bodies of the files.
     
    1. Issue the command to show the lines from all files in the current directory that "Daniel" authored.
    2. Issue the command to show the lines from all files in the current directory and down that "Daniel" authored.
    3. Now you are going to issue the command to show the lines from all files in the current directory and down that "Bob" authored, however Bob sometimes leaves the CAPS LOCK key on sometimes he does not. So we need to now search for files that Bob authored regardless of the case.
       
  9. I want you to now issue the same command that you did using the history in some way. How I don't care With the exception of the up arrow.
     
  10. Issue the command that will tell me where all the versions of the bash shell are. Meaning where all in my path can I find the executable called "bash"
     
  11. You will have probably noticed more than 1 version of bash sitting around on the Linux servers. Now issue the command to tell which one is being executed if you were to type the command bash.
     
  12. You will notice the file in the current directory called "names". If you were to look at the file you will have noticed that the names in this file are not in alphabetical order. I want you to issue the command the will sort these names in alphabetical order, and redirect its output (stdout) to a file called "names.sorted."
     
  13. Show the contents of this newly sorted file called "names.sorted.", it should be in alphabetical order.
     
  14. We looked at the file called "foo.c" the other day in class. Let's try to compile the file using gcc. This command is "gcc foo.c". You will notice errors. Let's redirect these errors (stderr) to a file called "errors".
     
  15. Now we will get some practice using the pipe. Issue the command that will show me all the users that are on the Linux server that you are on and pipe that commands output to the command that you would use to sort these names
     
  16. Next I want you to issue the command "ps -ax" and pipe the results into the command that you would use to search for the text "sshd" with.
     
  17. You are going to now issue the command "sleep 5". Notice that this will tie up your shell for 5 seconds (until the command is done executing). This would be the same as if you typed "xemacs" as a command.
     
  18. However let's run a command in the background (so it does not hold up our shell). This time issue the command "sleep 5" in the background. You will notice that you got your prompt back and can execute other commands. Wait about 10 seconds and then press enter. You should see that the shell told you that the command that you issued is now done.
     
  19. But lets simulate a command that we execute that stops responding. Issue the command "sleep 600". This will hold up the shell for a real long time (simulating an unresponsive command). I want you to issue the control sequence that will interrupt this command and stop it's execution.
     
  20. Again lets simulate a command that has stop responding. This time let's simulate that it was a job that was being run in the background. To do this type the command "sleep 600 &". You will get your prompt back.
     
  21. OK, we want to now terminate this program from running. In order to do this we must know it's process ID number. Issue the command that will show you what processes you have running, including this one that we just launched in the background.
     
  22. Look to the process ID number of the command "sleep". Issue the command that will terminate this process using the corresponding process ID number. Then press enter a couple of times. The shell should tell you that the process was terminated.
     
  23. OK, you are done with the assignment, all you need to do is to type "exit" to stop logging all of your commands.
     

Finally you will hand in the typescript file that you created. Email the typescript as an attachment to dhood2@cs.umbc.edu


Daniel J. Hood
Last modified: Sun Oct 10 20:05:43 EDT 2004