Updated: 2014-03-09 17:12 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.
10h00 (10am) Wednesday March 12, 2014 (middle of Week 9)
WARNING: Some inattentive students upload Assignment #6 into the Assignment #5 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.
fgrep
and grep
patterns to search the course notes for keywords.Remember to READ ALL THE WORDS to work effectively and not waste time.
This is an overview of how you are expected to complete this assignment. Read all the words before you start working.
You will create file system structure in your CLS home directory containing various directories and files. You can use the Checking Program to check your work as you do the tasks. You can check your work with the checking program as often as you like before you submit your final mark. Some task sections below require you to finish the whole section before running the checking program; you may not always be able to run the checking program successfully after every single task step.
Use a text editor to create your Start-Up Files login profile files .bashrc
and .bash_profile
.
Do some system administration tasks similar to Assignment #04.
When you are finished the tasks, leave these files, directories, and links in place on the CLS as part of your deliverables. Do not delete any assignment work from the CLS until after the term is over!
Assignments may be re-marked at any time on the CLS; you must have your term work available on the CLS right until term end.
All references to the “Source Directory” below are to the CLS directory ~idallen/cst8207/14w/assignment06/
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).
You do not have permission to list the names of all the files in the Source Directory, but you can access any files whose names you already know.
CST8207-14W
directory in your CLS HOME directory.Assignments
directory in the CST8207-14W
directory.assignment06
directory in the Assignments
directory.The correct directory tree will look similar to the ASCII tree diagram below. The spelling and capitalization must be exactly as shown.
CST8207-14W
`-- Assignments
`-- assignment06
This assignment06
directory is the base directory for most pathnames in this assignment. Store your files and answers below in this base assignment06
directory.
Run the Checking Program to verify your work so far.
Use a Linux text editor to create your .bash_profile
and .bashrc
files with the minimum suggested content described in the page Start-Up Files. (Your .bash_profile
must contain only one line. Your .bashrc
must contain at least two lines.)
Do not set any options or aliases in your .bashrc
that you do not understand! If you don’t know the meaning of a setting, don’t use it. You can RTFM in the bash
man page for all BASH settings, and RTFM in command man pages to learn about options to commands.
I will be spot-checking your knowledge of your aliases. Students using aliases they don’t understand will experience much confusion trying to do future assignments. Only use aliases you understand.
Using the PS1
variable from Worksheet #2 HTML, set your prompt to include your user name, your computer name, and the basename of your current working directory. Put this setting in your .bashrc
file.
Verify that nothing prints on your screen after you enter your password when you run the non-interactive shell connection using ssh localhost true
(as described in the section on Non-interactive shells and PS1:
$ ssh localhost true
*** COURSE LINUX SERVER ***
user@localhost's password:
$
For non-interactive commands to work properly, there must be no output on your screen after you enter your password using the above non-interactive command line using the true
command.
Your instructor will mark the .bashrc
and .bash_profile
files in your account on the assignment due date. Do not upload them to Blackboard. Leave them there on the CLS. Do not delete anything.
Run the Checking Program to verify your work so far.
Make a copy of the base3
directory from Assignment #04 into the base directory of this assignment using the name basecopy
here. Remember to preserve file attributes when you copy.
Rename all the directories by changing every occurrence of bdir
to just dir
in every pathname, e.g. basecopy/bdir2/bdir2-1/MT2-1
becomes basecopy/dir2/dir2-1/MT2-1
.
Make basecopy
your current directory and redirect the ten lines of recursive find
output into the file named basecopyfind.txt
in your base directory (not in the current directory). The word count of this file must be: 10 10 112
Run the Checking Program to verify your work so far.
Under the Source Directory there is a name maze
that is a symbolic link that leads to the same directory maze used in a previous assignment: Assignment #04 HTML.
In the maze use a single command (not a pipeline) to recursively find all pathnames with a basename that begins with your eight-character userid at the start of the name. For example, if your userid were abcd0001
then you might output pathnames containing basenames such as abcd0001
and abcd0001YYY
but not XXXabcd0001
or XXXabcd0001YYY
where XXX
and YYY
can be anything (zero or more characters). You will find exactly 15 pathnames.
Modify the same single command you used to find the names above and instead use the option that makes the command show the full information about the names (including permissions, owner, size, date, etc.) instead of just the pathname. You will know you have the right option if the output of the command shows 15 lines and 168 words.
Pipe the pathname output of the above command (15 lines of output) into a sorting program and put the reverse-sorted output into file mazefoundreverse.txt
under your base directory. The reverse-sorted file will still contain 15 lines and 168 words.
Run the Checking Program to verify your work so far.
Use the options to fgrep
that ignore case and “show files with matches” (RTFM) and find the 23 file names that contain the exact string symbolic link
in all the files ending in .txt
in the previous term course notes. Exactly 23 file names will print, and one of the pathnames will end in basename 750_booting_and_grub.txt
. Hint: Use the oldnotes
symbolic link from Assignment #04 and a GLOB pattern that matches all the .txt
files under it, using the fgrep
method described in Copies of the CST8207 Course Notes.
Now redirect the 23 names into file symlinkfound.txt
under your base directory. The file must contain 23 lines ending in the .txt
suffix.
Run the Checking Program to verify your work so far.
Use a two-command pipeline to find every line containing the string new denied hosts
that appears in January in the denyhosts
log file. (This log file is in the same directory as the auth.log
file used in class.) You should find 188 matching lines in the file. (Hint: See your class notes from Week 05 Notes. How do you know which lines in the denyhosts
file were created in January?)
['50.46.204.2']
and the last line (of 188) will be ['222.186.62.56']
.Put a copy of the three-command pipeline into file denygrep.sh
in the base directory. (Put the command pipeline in the file, not the output of the command.) If you execute sh ./denygrep.sh
the output should word count as 188 lines and 188 words, with either 3372 or 3373 characters (depending on how you extracted the IP address field).
Run the Checking Program to verify your work so far.
Follow correct double-quoting procedures when expanding variables, as noted in Shell Variables.
Display the value of the environment variable containing your userid. Put the command you use to do this into file env.sh
in the base directory. (Put in the command, not the output.) The file will contain one command line.
Display the value of the environment variable containing your home directory. Append the command you use to do this to file env.sh
in the base directory. (Put in the command, not the output.) The file will contain two command lines.
Display the value of the environment variable containing your assigned shell. Append the command you use to do this to file env.sh
in the base directory. (Put in the command, not the output.) The file will contain three command lines.
Display the value of the environment variable containing your shell search path. Append the command you use to do this to file env.sh
in the base directory. (Put in the command, not the output.) The file will contain four command lines.
Run sh ./env.sh
and the values of all four environment variables should display on your screen.
Run the Checking Program to verify your work so far.
Make the above assignment06
base directory your current directory.
Copy the script file quotes.sh
from the Source Directory into the current directory.
Execute this file (enable execute permissions and then run it) or use bash
to read the file so that all the commands inside it execute:
$ chmod ugo+x quotes.sh
$ ./quotes.sh
** - OR USE BASH: - **
$ bash ./quotes.sh
Note that the output of running the script generates an error message and doesn’t match what is written in the script file. (For example: many quotes are missing, GLOB characters and variables are expanding, and the spacing of the words is different.)
Fix the Quoting inside the file so that every line is fully quoted to appear exactly as written in the file, blanks included, with no meta-character expansion by the shell. The correct output should give eight lines and look exactly like this when you are finished (including all the extra spaces between some of the words):
Where is the question mark after the file /etc/group?
Is one also missing after /etc/passwd?
The shell prompt is contained in the $PS1 variable.
This line isn't appearing on my screen properly. It's missing the quotes.
This line is also "missing" all the quotes. It is not "right" yet.
This is also "missing" all quotes. It's output that doesn't make sense.
This isn't working either. The shell gives an error message.
*** This is a file to practice shell quoting. Do you see this line? ***
You must edit the file to make the entire line of text on each line one single shell argument to echo
. You can check your success by temporarily substituting the argv.sh
program from the Class Notes for the echo
command. (You have to put the argv.sh
program into the same directory as quotes.sh
under the name argv.sh
and make it executable. Read the quotes.sh
file for details on using an alias inside the quotes file to run this program. Remember to return the script to using only echo
after you finish your testing.)
You’ll know you got it mostly right when you see this wc
and sum
output (but you’ll need to verify one-argument-per-echo using the argv.sh
program):
$ ./quotes.sh | wc
8 86 500
$ ./quotes.sh | sum
39574 1
If your line and word count is correct but the number of characters is less, you probably failed to make the entire text one argument to echo
on each line. You must use Quoting to hide all the blanks and special characters from the shell on each of the lines. The argv.sh
program will tell you if you got it right.
When the edited script output is correct, run the script and redirect the script output into file quotesout.txt
Run the Checking Program to verify your work so far.
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.
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.
There is a Checking Program named assignment06check
in the Source Directory on the CLS. You can execute this program by typing its (long) pathname into the shell:
$ ~idallen/cst8207/14w/assignment06/assignment06check
Execute the above “check” program. 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.
assignment06.txt
under your assignment06
directory on the CLS. Use the exact name assignment06.txt
in your assignment06
directory. Case (upper/lower case letters) matters. Be absolutely accurate, as if your marks depended on it. Do not edit the file.
YOUR MARK for
assignment06.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.
YOUR MARK for
Submit the assignment06.txt
file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the assignment06 “Upload Assignment” facility in Blackboard: click on the underlined assignment06 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 need to comment on any assignment submission, send me email.
You can upload the file more than once; I only look at the most recent. You must upload the file with the correct name; you cannot correct the name as you upload it to Blackboard.
You will also see the Review Submission History page any time you already have an assignment attempt uploaded and you click on the underlined assignment06 link.
You cannot delete an assignment attempt, but you can always upload a new version. I only mark the latest version.
Your instructor may also mark files in your 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!
I do not accept any assignment submissions by email. Use only the Blackboard Attach File. No word processor documents. Plain Text only.
Use the exact file name given above. Upload only one single file of plain text, not HTML, not RTF, not MSWord. No fonts, no word-processing. Plain text only.
Did I mention that the format is plain text (VIM/Nano/Pico/Gedit or TextEdit 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 16-character, lower-case 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!