Updated: 2017-05-31 12:15 EDT
Do not print this assignment on paper!
- On paper, you will miss updates, corrections, and hints added to the online version.
- On paper, you cannot follow any of the hyperlink URLs that lead you to hints and course notes relevant to answering a question.
- On paper, scrolling text boxes will be cut off and not print properly.
08h00 (8am) Monday November 25, 2013 (start of Week 13)
WARNING: Some inattentive students upload Assignment #11 into the Assignment #10 upload area. Don’t make that mistake! Be exact.
Do not print this assignment on paper. On paper, you cannot follow any of the hyperlink URLs that lead you to hints and course notes relevant to answering a question.
This assignment is based on your weekly Class Notes.
This is an overview of how you are expected to complete this assignment. Read all the words before you start working.
Practice controlling Processes and Jobs.
Search System Log Files.
Schedule jobs using Crontab and At.
Review minimal permissions from Worksheet #08.
Since I also do manual marking of student assignments, your final mark may not be the same as the mark submitted using the current version of the Checking Program. I do not guarantee that any version of the Checking Program will find all the errors in your work. Complete your assignments according to the specifications, not according to the incomplete set of the mistakes detected by the Checking Program.
All references to the “Source Directory” below are to the CLS directory ~idallen/cst8207/13f/assignment11/
and that name starts with a tilde character ~
followed by a userid with no intervening slash. The leading tilde indicates to the shell that the pathname starts with the HOME directory of the account idallen
(seven letters).
Create the following directory structure in your CLS HOME directory and record (for study purposes) the series of Unix commands you used to create it. Spelling and capitalization must be exactly as shown:
CST8207-13F
`-- Assignments
`-- assignment11
This directory is the base directory for most pathnames in this assignment. Store your files and answers here.
There is a Checking Program named assignment11check
in the Source Directory on the CLS. Follow the instructions in the first two steps at the start of Checking Program to create a working symbolic link to this program.
Review Processes and Jobs.
Place a full list of all processes for all users, BSD format, all users, text user name (not numeric UID), full wide listing (not truncated at all), into file psbsd.txt
in your assignment11
directory. It should be “at least” 105 lines and 9KB. One of the very long lines will be a dhclient
line similar to this (use fgrep
to find it in the output):
root 3171 0.0 0.0 7268 436 ? Ss Oct26 0:00 dhclient3 -e IF_METRIC=9999 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -1 eth0
Place a full list of all processes for all users, UNIX (System V) format, text user name (not numeric UID), full wide listing (not truncated at all), into file psunix.txt
in your assignment11
directory. It should be “at least” 105 lines and 7KB. One of the very long lines will be a dhclient
line similar to this (use fgrep
to find it in the output):
root 3171 1 0 Oct26 ? 00:00:00 dhclient3 -e IF_METRIC=9999 -pf /var/run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases -1 eth0
Review System Log Files.
What is the actual name of the syslog program on the CLS? Extract the one line from each file psbsd.txt
and psunix.txt
that contains this name and redirect the results (two lines, one from each file) into file syslog.txt
. (The result will be 2 lines, 21 words.)
The system authentication log file is named auth.log
in the system log directory. Generate an ls
long listing of this file using the full absolute pathname, and put the results into file authlog.txt
. (The result will be 1 line, 9 words, at least 64 characters.)
(Optional: You may find it convenient to set a shell variable to this absolute pathname, so that you can use the short variable name rather than the long absolute pathname in the rest of these exercises. Or, you could make a short symbolic link to this file.)
Put a list (one line) of your userid, UID, group, GID, and additional groups into the file id.txt
. (The result will be 1 line, 3 words.) (See Permissions for the command to use to do this. Do not edit the output of the command.)
Look at the contents of the id.txt
and authlog.txt
files. Note that your account is in a group that matches the group of the system auth.log
file, giving you group permissions on this file. Using a text editor, put the matching group name (three characters), the symbolic group permissions (three characters), and the octal group permissions (one digit), onto three lines in file myperms.txt
. (The result will be 3 lines, 3 words, 10 characters. Do you remember why a line containing seven alphanumeric characters on three lines is counted as a 10-character file?)
The system auth.log
file contains over 643,480 lines. Use a command to extract just the first line (one line) from the head of this file and redirect that one line into new file authhead.txt
. (The result will be 1 line 14 words 109 chars.) The time and date at the start of this line is when this copy of the log file was started.
If you count the number of lines in the system auth.log
containing the exact text string Failed password
, the count is more than 2,170 lines. Of those lines (the lines containing that text string), extract just lines 1000 through 1010 (inclusive) and put those 11 lines into file failedpass.txt
. The word count for the file will be 11 162 1219
. Every line should contain the text string somewhere.
The CLS is running the denyhosts
package to blacklist attacking machines. It logs its activity in the expected denyhosts
log file. Look (fgrep
) in this file for the line for the text new denied host
that was logged on November 1 2013 and redirect that one line into file badhost.txt
(word count 1 10 87
). Hint: Use a pipeline with two fgrep
commands to find the only line that matches both the date and the desired text. You will need to search for the date in the format that it appears in the log file.
In the auth.log
file search for all lines containing the IP address of the attacking machine (that IP address is the one IP address in the one line you just put in badhost.txt
) to find out why that IP address was blacklisted. Redirect the output into file badauth.txt
. The result will be at least 7 lines 88 words 807 chars. (It may be more, if they attack again!) Every line of output will contain that attacking IP address somewhere in the line.
Warning! Do not run the whois
command more than absolutely necessary, since too many uses may result in us being cut off from using the whois
database! Run the whois
command (once!) and find out who owns this attacking IP address. Put the two output lines from whois
containing the string descr:
into file baddescr.txt
. The result will count as 2 13 130
.
Feel free to explore some other attacking IP addresses to learn what it’s like having a machine exposed on the Internet.
Review Crontab and At.
Create a personal crontab
entry that updates the modification time on file crontab.txt
in your assignment11
directory (not in your HOME
directory) every minute of every day. Use the shortest relative pathname to your crontab.txt
file. Do not use an absolute pathname. Verify that the modification time of the file changes every minute. (If it doesn’t work, read your Linux email for email messages from the Cron daemon showing possible errors.)
List your personal crontab
(one entry) and redirect the output into file crontab1.txt
.
Delete your personal crontab
.
Create a personal crontab
entry that updates the modification time on the same file crontab.txt
at exactly 7:34 PM every evening. (Also use a relative pathname, not an absolute pathname.)
List your personal crontab
(one entry) and redirect the output into file crontab2.txt
. Do not delete this crontab
entry; leave it for marking.
Create an at
job that updates the modification time on the file atjob.txt
(in your assignment11
directory, not in your HOME
directory) one or two minutes from now. (Check the current system time and add a minute or two. Look at the queue of at
jobs and make sure the scheduled job time is correct.) Make sure that the file time changes one or two minutes from now. (If it doesn’t work, read your Linux email for email messages from the At daemon showing possible errors. Also check the queue of at
jobs and make sure the job isn’t queued later than you think it is.)
Make assignment11
your current directory and then create an at
job that updates the modification time on the file atjob.txt
(in your current directory, not in your HOME
directory) at the start date and time of your CST8207 final exam. Again, check the queue of at
jobs and make sure the scheduled time is correct. Leave this job queued on the CLS for marking.
Display all your queued at
jobs and redirect the output into file atjob.txt
. (You will only have one job – one line.) (If you have more than one line, delete the other jobs.)
Copy this text into file minimal.txt
and replace all the underscore characters using your answers from Worksheet #08. Missing permissions should be given as dashes so that each set of three underscores is replaced with exactly three other characters:
*** Table of MINIMUM rwx symbolic permissions ***
1. copy a file: srcdir=___ srcfile=___ targetdir=___
2. move a file: srcdir=___ srcfile=___ targetdir=___
3. link to a file: srcdir=___ srcfile=___ targetdir=___
4. delete a file: srcdir=___ srcfile=___
5. read a file: srcdir=___ srcfile=___
6. modify an existing file: dir=___ oldfile=___
7. create a new file: dir=___
The original file and the edited file must both have 8 lines and 55 words.
That is all the tasks you need to do.
Check your work a final time using the Checking Program and save the output as described below. Submit your mark following the directions below.
Summary: Do some tasks, then run the checking program to verify your work as you go. You can run the checking program as often as you want. When you have the best mark, upload the marks file to Blackboard.
There is a Checking Program named assignment11check
in the Source Directory on the CLS. Create a Symbolic Link to this program named check
under your new assignment11
directory so that you can easily run the program to check your work and assign your work a mark. Note: You can create a symbolic link to this executable program but you do not have permission to read or copy the program file.
Execute the above “check” program using its new symbolic link. (Review the Search Path notes if you forget how to run a program by pathname from the command line.) This program will check your work, assign you a mark, and display the output on your screen. (You may want to paginate the long output so you can read all of it.)
You may run the “check” program as many times as you wish, to correct mistakes and get the best mark. Some task sections require you to finish the whole section before running the checking program at the end; you may not always be able to run the checking program successfully after every single task step.
When you are done with checking this assignment, and you like what you see on your screen, redirect the output of the Checking Program into the text file assignment11.txt
under your assignment11
directory. Use the exact name assignment11.txt
in your assignment11
directory. Case (upper/lower case letters) matters. Be absolutely accurate, as if your marks depended on it. Do not edit the file. Make sure the file actually contains the output of the checking program!
Transfer the above assignment11.txt
file from the CLS to your local computer and verify that the file still contains all the output from the checking program. Do not edit this file! No empty files, please! Edited or damaged files will not be marked. You may want to refer to your File Transfer notes.
Submit the assignment11.txt
file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the assignment11 “Upload Assignment” facility in Blackboard: click on the underlined assignment11 link in Blackboard. Use “Attach File” and “Submit” to upload your plain text file.
No word-processor documents. Do not send email. Use only “Attach File”. Do not enter any text into the Submission or Comments boxes on Blackboard; I do not read them. Use only the “Attach File” section followed by the Submit button. (If you want to send me comments about your assignment, use email.)
Your instructor may also mark the assignment11
directory in your CLS account after the due date. Leave everything there on the CLS. Do not delete any assignment work from the CLS until after the term is over!
Use the exact file name given above. Upload only one single file of plain text, not HTML, not MSWord. No fonts, no word-processing. Plain text only.
Did I mention that the format is plain text (suitable for VIM/Nano/Pico/Gedit or Notepad)?
NO EMAIL, WORD PROCESSOR, PDF, RTF, or HTML DOCUMENTS ACCEPTED.
No marks are awarded for submitting under the wrong assignment number or for using the wrong file name. Use the exact name given above.
WARNING: Some inattentive students don’t read all these words. Don’t make that mistake! Be exact.
READ ALL THE WORDS. OH PLEASE, PLEASE, PLEASE READ ALL THE WORDS!