CS253 Lab 2
Due Monday, September 2
Lab 2 will be created and turned in just like lab 1, except you should name the file lab2. As before, correct file naming and permissions are part of the grade for the assignment.
Here are the questions for lab 2. Suggested programs to answer the question are given in bold, but these can generally be answered in a variety of ways. Most of these require use of pipes.
- Write a command or sequence of commands that lists all users who logged in on a Thursday. last, grep
- 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
- The logs for the web server on isoptera are stored in /var/log/nginx. 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 lab2.html was requested in access.log and access.log.1. grep, wc
- Write a command that determines how many files are located in /etc, including subdirectories. find, wc
- Write a command which displays ONLY the current IP address of the computer. For isoptera, this address is 74.118.22.194, but create a command that will work even if the IP address is different. 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 lab2
This assignment is worth 35 points, 5 from correct naming, 5 from correct permissions, and 5 from each of the questions above.