CSCI 3294 (Seminar: UNIX Power Tools), Fall 2016:
Homework 2

Credit:
30 points.

Reading

Be sure you have read, or at least skimmed, the assigned readings for 9/07 and 9/12.

Honor Code Statement

Please include with each part of the assignment the Honor Code pledge or just the word ``pledged'', plus one or more of the following about collaboration and help (as many as apply).1Text in italics is explanatory or something for you to fill in. For written assignments, it should go right after your name and the assignment number; for programming assignments, it should go in comments at the start of your program.

Problems

Answer the following questions. You may write out your answers by hand or using a word processor or other program, but please submit hard copy, either in class or in one of my mailboxes (outside my office or in the ASO). Answers to most questions will involve experimentation on a UNIX or Linux system. You are free to use any appropriate system (unless a specific problem says otherwise); if you use something other than one of our classroom/lab machines please tell me what.

Filter programs and other useful commands

  1. (5 points) When a new user account for the department's lab machines is created, part of the setup procedure is to create a home directory in /users and copy into it certain files from /etc/skel. What command could you use to compare the files in your home directory to the files in /etc/skel (including any files in subdirectories), for example to find out whether you had inadvertently changed or deleted something that might be important? (Hint: You can do this with one command. For most-accurate results, you probably need to run this on the machine on which accounts are created. I will mention its name in class.)

  2. (5 points) What would you type at the command line to find all files in your home directory (and all subdirectories) that are less than a day old and end with .c?

I/O redirection and pipes

  1. (5 points) How would you invoke the gcc compiler if you want to be able to page through its output (both standard output and standard error) with less?

    How would you capture the error output only in a file called gcc-ERRORS?

  2. (5 points) How could you make a one-line text file without using a text editor? Could you extend this idea to make a multiline text file? Tell me about as many ways to do this as you can think of.

  3. (5 points) What would you type at the command line to get a sorted list, with no duplicates, of all the users running processes on the machine you're using, along with a count of processes they're running?

  4. (5 points) Answer/do one of the following:

    1. What would you type at the command line to find out how many processes are being run by user root?

    2. Describe something you actually want to do (e.g., archive all files that have been changed in the last 24 hours, find a classroom machine that's up and connect to it with ssh) and a solution involving a pipe and at least one of the commands mentioned in the reading for this assignment.



Footnotes

... apply).1
Credit where credit is due: I based the wording of this list on a posting to a SIGCSE mailing list. SIGCSE is the ACM's Special Interest Group on CS Education.


Berna Massingill
2016-10-31