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

Credit:
40 points.

Reading

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

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.

How to find out information

(You will learn more about this topic if you use the man and info commands rather than Google!)

  1. (5 points) When you are reading a man page, is there a way to search for particular text? What is it?

    (Hint: Look in the man page for man for mentions of a pager, and then read the man page for the appropriate other program.)

  2. (5 points) What command(s) could you use to find out how much disk space is available on all the mounted disks? What command(s) could you use to find out how much disk space is taken up by all the files in your home directory?

    (Hint: man -k or apropos may be helpful.)

  3. (5 points) The Linux date command will, among other things, print today's date or a specified other date. How would you use this command to find out what day of the week you were born? (I.e., tell me the line or lines you would type in a terminal window to accomplish this.)

    (Hint: The info page for date may be more helpful than the man page.)

    (To observe how UNIX systems are sometimes not alike, if you have access to an OS X (Mac) machine, try the same command on it.)

Files and filesystem basics

  1. (5 points) On one of the lab machines, the command ls -l /bin/vi produces the following output:

    -rwxr-xr-x 1 root root 721952 Mar 25 18:24 /bin/vi

    What does all of this mean? (I.e., what does the string of dashes and letters mean? The 1? The 721952? and so on.)

    (Hint: man ls and info ls may be helpful.)

  2. (5 points) What command(s) would you use to create a directory in your home directory called KeepOut to which you have full access (read, write, and execute), but no one else has any access?

Processes and job control

  1. (5 points) Suppose you have started a GUI application called bigpig that for some reason doesn't seem to be responding to any input. How do you terminate it without logging out or rebooting the machine? Describe as many ways as you can think of.

    (Hint: man ps and man kill.)

Shell basics and customizations

(Answer the following questions for the bash shell.)

  1. (5 points) When you type a command (e.g., ls), the shell has to find an executable (program) to run. Where does it look? How could you make it also look in your directory MyPrograms (in addition to wherever it looks now)? How could you make it look only in your directory MyPrograms?

  2. (5 points) Give the command(s) you would use to define two aliases or shell functions: delete to move a file to be ``deleted'' to a temporary directory such as $HOME/.trash, and undelete to move a ``deleted'' file from the temporary directory to the current directory. (Examples of use: delete myfile, undelete otherfile.)

    (It's up to you to decide whether these should be aliases or shell functions. You might be constrained by the capabilities of aliases versus functions.)

    Notice that commands to define aliases or functions can be entered from the command line, in which case they apply to the current session only, or can be included in an appropriate initialization file.



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