CSCI 3190 (Directed Study (Unix Power Tools)), Spring 2004:
Homework 2

Assigned:
February 5, 2004.

Due:
February 9, 2004, at 5pm.

Credit:
10 points.

Reading

Read about the following topics, either by skimming the mentioned online references or in another book or reference.

  1. Shell basics (control keys, command history, environment variables). Partly covered in section 2 of Introduction to Linux. Covered in more detail in sections 3 and 8 of the GNU Bash Reference Manual.

  2. Processes and job control. Partly covered in section 4 of Introduction to Linux. Some aspects covered in more detail in section 7 of the GNU Bash Reference Manual.

  3. Input/output redirection. Covered in section 5 of Introduction to Linux.

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 my mailbox in the department office. Answers to most questions will involve experimentation on a Unix or Linux system. You are free to use any appropriate system; if you use something other than Red Hat Linux please tell me what.

Shell Basics

  1. (2 points) The man page for bash says that you can search forward through the command history using control-S. When I try this, my bash session goes into a state in which it doesn't seem to be responding to input. Do you see similar behavior? What has happened? What do you have to do to get bash to respond again?

    (Hint: man stty and search for ``stop''.)

    For extra credit, is there a way to make control-S work the way the man page for bash says it should work?

  2. (2 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? (Your solution can be one that only applies to the current session, i.e., until you log out.)

Processes and Job Control

  1. (2 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.)

I/O Redirection and Pipes

  1. (2 points) How would you invoke the g++ 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 in a file called gcc-ERRORS?

  2. (2 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? Can you think of more than one way to do this?



Berna Massingill
2004-02-12