Unix Systems Programming: Lab 1

Lab time:    No assigned lab time due to lab space construction.  Work at your own pace, but work.
Due:           Monday, October 1, by 5:00 pm.


PURPOSE AND RATIONALE

The purpose of this lab is to quickly get students up to speed with basic usage of the Unix development environment, as a preparation for all future lab activities.

PRIMARY RESOURCES:

FAQ(submission instructions and other useful stuffs)
You should refer to relevant sections of the man pages for assistance for this lab, in addition to materials in your assigned primary texts for this week.
If possible, you should ssh into the cluster to perform all lab activities.

README

  1. If you are not in our course email list, please subscribe to the cspp51081 email list here:http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51081
  2. Turn the lab assignment in by email to the grader by the due date above.
  3. For printing out your documents, you might find the following commands useful during your year(s) in this department:
    1. lpr -  off line print. Note that this command is called when you print from acroread  (for .pdf files) or gv (for .ps files)
    2. lpq - shows the printer queue
    3. lprm - removes jobs from the printer queue
    4. enscript - converts text files to PostScript (useful when you want to print out text files)
  4. Make sure you have read the Homework Style Guidelines for submission.

LAB 1

  1. In your home directory create the subdirectory ~/cspp51081/labs/lab1 . (Use multiple mkdir commands or consult the -p option for mkdir in the man page for mkdir).
    1. cd ~/cspp51081/labs/lab1
    2. Copy or create a file named myfile into ~/cspp51081/labs/lab1 (if you create it, type something into it).  For information on how to create a quick empty file, man touch.
    3. Create a soft link soft_link and a hard link hard_link to that file.
    4. Based on the output returned by stat and ls commands (using all relevant options),  explain in detail (but briefly) the differences between the three files.
  2.  Read the man pages for the following commands:
  3. The objective of this exercise is to demonstrate in a reasonably small (the smaller the better) number of commands that you understood how to use the commands above and when they are useful.
    Create a transcript that shows you understand the commands listed above.  By transcript, I mean a file that shows the output of your session.  See this example.  Yours will be longer.  You can use the script command to create the transcript, or you can cut and paste, whatever works for you.  In your transcript file please show:
    1. How many John's (first name) have user accounts on the department's computers [a single pipeline of 3 processes]. Hint: use grep, also look at wc.
    2. Show the jobs in the printer queue. [3 characters if you're lucky] (What printer is your default printer, by the way? See it also with echo $PRINTER. No need to show this in the transcript)
    3. Change your file permission mask such that by default your colleagues do not have read permissions for your newly created files. Please show in the transcript file the following:
    4. List the PIDs of all processes running as root on your computer on a line, separated by commas. E.g.,: 1,2,3,4,5,657,658, ... Use pipes to create a one-line command that accomplishes this. You'll need some of the text processing tools presented in class. Hint: man ps (-a and -x flags), man tr.
    5. List the usernames and names of the people logged on harper.uchicago.edu . (NOTE:  you may find the command option of ssh helpful.) The list returned should be sorted, should not contain duplicates (e.g., same user listed multiple times) and should have the following format:
        1. 1 <username1> <name1>
          2 <username2> <name2>
          3 <username3> <name3>
          ...
      Hints: use the "nl" command to number lines.
  4. Explain in English what information you can get about ~mark/pub/51081 using all (and only) relevant options of ls and stat commands: (is it a file? a directory? how large? permissions? access info? etc.) Indicate the fields that reveal these pieces of information.

More information:

GNU text utilities (renamed "GNU coreutils")
Unix Reference Desk
Hobbes' Internet Timeline (just for fun)
 

Ross Girshick