CS228 Homework 2

Due Monday, January 29, at 10:30 AM

Homework 2 will be created and turned in just like homework 1, except you should name the file homework2. As before, correct file naming and permissions are part of the grade for the assignment. Here are the questions for homework 2. Suggested programs to answer the question are given in bold. Most of these require use of pipes.
  1. Write a command or sequence of commands that lists all users who logged in on a Saturday. last, grep
  2. There is a file called poem located in /tmp. Write a command which prints out the number of lines of this poem that contain the word "the". grep, wc
  3. The logs for the web server on isoptera are stored in /var/log/apache2. This directory contains access.log, which is the current log of requests. It is periodically renamed access.log.1, and a new log is started as access.log. Write a command which determines how many times a page named h2.html was requested in access.log.1. grep, wc
  4. Write a command that determines how many files are located in /etc, including subdirectories. find, wc
  5. Write a command which displays ONLY the current IP address of the computer. For isoptera, this address is This is on the second line of the output from ifconfig. Once you have isolated this line (grep, head ), you can use head and tail to trim off the beginning and end of the line, leaving only the IP address. See the manual or use the --help option to determine how to trim a single line using head and tail. As an optional improvement, you can use grep to put a newline back on the end (pipe the result into grep, and search for a period). If you have trouble running ifconfig, try specifying the complete path (/sbin/ifconfig)
Here is the command to set the permissions:
chmod 600 homework2
This assignment is worth 35 points, 5 from correct naming, 5 from correct permissions, and 5 from each of the questions above.