Updated: 2014-10-30 12:02 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.
12h00 (noon) Monday October 27, 2014 (start 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.
$PATH
.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.
For full marks, follow these directions exactly.
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.
When you are finished the tasks, leave these files and directories 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/14f/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.
Do a Remote Login to the Course Linux Server (CLS) from any existing computer, using the host name appropriate for whether you are on-campus or off-campus.
Make the CLS directory ~/CST8207-14F/Assignments/assignment06
, in which you will create the files and scripts resulting from the following tasks.
This
assignment06
directory is the Base Directory for most pathnames in this assignment. Store your files and answers in this Base Directory.
Run the Checking Program to verify your work so far.
You must know how to use a text editor and understand how shells use Quoting to do this task.
Make the Base Directory your current directory.
Copy the script file badquotes.sh
from the Source Directory into the current directory using the new name goodquotes.sh
as you copy it.
Enable execute permissions on the script file and then run it using these two command lines:
$ chmod ugo+x goodquotes.sh
$ ./goodquotes.sh
Remember how to make a file executable and run it from the current directory; you will need this again.
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.
Use a text editor to add Quoting inside the script file so that every line is fully quoted to echo
onto your screen exactly as written in the file, blanks included, with no meta-character expansion by the shell. The correct ten lines of output should 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?
Do you see *[square]* *[brackets]* ?
The shell prompt is contained in the $PS1 variable.
This isn't appearing on my screen properly. It's missing the quotes.
This is also "missing" all the quotes. It is not "right" yet.
This is also "missing" 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? ***
Do you see this last line with the extra spaces?
When the edited script output is correct, run the script and redirect the script output into file goodquotesout.txt
in your Base Directory (the current directory).
Hints:
You must edit the goodquotes.sh
file to make the entire line of text on each line one single shell argument to echo
. Review how the shell finds arguments and how to use Quoting to hide shell metacharacters.
You can check whether you have successfully created one single argument on each line by temporarily substituting the argv.sh
program from the Class Notes for the echo
command.
You can easily get a copy of the argv.sh
program from the course notes on the CLS using the newnotes
symbolic link you created in a previous assignment.
Read the goodquotes.sh
file for details on using an alias inside the quotes file to run argv.sh
. You have to put the argv.sh
program into the same directory as goodquotes.sh
under the name argv.sh
and make it executable. Remember to undo the alias and return the script to using only echo
after you finish your testing.
Once you have created a non-empty goodquotesout.txt
file, the Checking Program will tell you the expected word count. 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.
Run the Checking Program to verify your work so far.
PATH
You must know how to use a text editor understand how a shell uses a search PATH
to do this task.
Use a text editor to create a file named pathcheck.sh
under the Base Directory. This file will contain exactly four lines of text:
PATH
variable to include the Source Directory for this assignment appended at the (right) end of the path. Append to the existing PATH
variable, as shown in the course notes.echo
the new value of PATH
onto your screen. Follow correct double-quoting procedures when expanding variables, as noted in Shell Variables.assignment06check
(the basename of the Checking Program), which it will do using the modified PATH
you set at the top of the script. No slashes should appear in this command name, so that the shell uses your modified $PATH
, set on the first line, to find it and run it. (Review how the shell search PATH
works.)After you have created your four-line shell script, make the file executable, and then run it. (Use the same method as you did with the quotes script in a previous task, above.)
When you run the script, each of the four command lines in the script will execute, one after the other. The first line, setting the search path, should produce no output. There will be three outputs that come from the next three lines of the script:
PATH
,assignment06check
checking program should start running.Hints:
PATH
variable to find and run commands.PATH
.command not found
output coming from commands inside the executing script, you have either spelled a command name incorrectly or have not correctly set the shell search path inside the script file. This script will only work if the shell search PATH
is set correctly at the beginning (top) of the file.Run the Checking Program to verify your work so far.
You need to understand Hard Links and Disk Usage to do this task.
For the next task, you will need to look up the copy option that means archive that preserves hard links (as well as all the other attributes) when you copy a directory (RTFM).
DiskUse/
abcd0001
(where abcd0001
is replaced by your own userid). Copy, using the archive option, this directory into your Base Directory using the name DiskUse
. You will know you got it right if your personal copy of the DiskUse
directory has the same disk use summary (du -s
) as the one in the Source Directory.Your personal copy of the DiskUse
directory contains exactly four sub-directories, each of which contains many other files and sub-sub-directories. (If you don’t see four sub-directories, read all the Hints.) A recursive list of pathnames counts 302.
There are four levels of difficulty in this task, one for each of the four sub-directories in your personal DiskUse
directory.
In your personal DiskUse
directory, some of the files are hard links to each other. (If there are no hard links anywhere, you didn’t use the archive option to the copy command that preserves hard links. Delete everything and re-copy.)
Read this task all the way through, especially the Hints, before you delete anything, or else you will have to start over again.
There are four levels of difficulty. Do the easy one first, followed by medium, followed by hard, followed by ugly:
DiskUse
directory that contains the text easy
in the name. Make this your current directory.Under the current directory, there is a directory named foo
.
Reclaim all the disk space used by the files under foo
by removing all the files under foo
and any hard links to those files. Some of those hard links may be to files in other sub-directories under the current directory; you don’t have to scan the whole file system to find the hard links.
Run the Checking Program to verify your work so far.
Locate the sub-directory of your personal DiskUse
directory that contains the text medium
in the name. Make this your current directory. Repeat the steps A through C above.
Locate the sub-directory of your personal DiskUse
directory that contains the text hard
in the name. Make this your current directory. Repeat the steps A through C above.
Locate the sub-directory of your personal DiskUse
directory that contains the text ug1y
in the name. (Note carefully the spelling.) Make this your current directory. Repeat the steps A through C above.
Hints:
Many of the files in each foo
subdirectory have more than one name. Those other names may be located somewhere else in the current directory, for each of the difficulty levels. (You don’t have to search the whole disk partition to find them.) The disk blocks for these files in foo
will not be freed until you find and remove all their names. Do not remove any names from foo
until you also know how to find and remove all the other names for these files. You will need to look at inode numbers to know which files in directory foo
are also named in the other directories. You read about how to do this in Disk Usage.
Options to ls
to display hidden names and nongraphic (unprintable) characters will be needed for the harder sections. Many names will need to be quoted to hide shell metacharacters (see Quoting).
If you don’t get the right answer for a difficulty level, you can start over by re-copying all or part of the DiskUse
directory from the Source Directory.
If you make errors in this task and need to redo one of the four sections, you can remove and re-copy from the Source Directory just the sub-directory for that section. You don’t have to remove and re-copy the whole DiskUse/
abcd0001
directory, since that would lose the work you did on the other sections.
If you do want to remove your entire personal DiskUse
directory to start over, you will need to redo all four levels. If you are smart and rename the directory instead of removing it, you can salvage from the saved directory the parts of the task you have already done successfully, so you won’t have to redo those parts.
If you find that you don’t own any of the files under DiskUse
, and that you have no permission to remove any files, then you didn’t copy the files correctly. Re-read that first step.
Run the Checking Program to verify your work so far.
You need to understand Symbolic Links to do this task.
check
in your Base Directory that links to the Checking Program in the Source Directory.Instead of typing the huge absolute pathname when you want to run the Checking Program, all you need to type is the short name of this symlink, which now points to the long pathname.
Use your symbolic link ./check
to run Checking Program to verify your work so far.
You already created symbolic links to
oldnotes
andnewnotes
in a previous assignment. These (shorter) symbolic links let you access the course notes using much shorter pathnames. Sysadmin often create (shorter) symbolic links to long pathnames that they use frequently.
You need to understand Hard Links and Symbolic Links and to do this task.
In your Base Directory, create a sub-directory and an empty file ln/
abcd0001.txt
(no spaces), where the text abcd0001 is replaced by your own eight-character userid in the file name. NOTE: The sub-directory name is ln
(two letters), not 1n
(digit letter).
For every unique character in your own eight-character userid, create a sub-sub-directory under ln
with that single-character name.
For example, the userid abca0151
would result in six unique sub-sub-directory names under the ln
directory – one sub-sub-directory for each of the unique characters a
, b
, c
, 0
, 1
, 5
. (You can create multiple directories with one single command line.)
Do this for your own userid, which means you may have more or fewer sub-sub-directories, depending on the letters and digits in your own userid.
Inside each of those new sub-sub-directories, create a single Hard Link to the empty file from the first step. Keep the same file name as the original for each hard link you create. Use hard links, not symbolic links.
Continuing the above example, the abca0151
user would hard link the original empty file name abca0151.txt
into each of those six new sub-sub-directories, creating six additional names for the same file. Keep the same file name as the original for each hard link.
Check the link counts on everything to make sure that you have created links to the same file and not made copies of the file. Use hard links, not symbolic links.
For every lower-case letter directory name you created, create a short, relative Symbolic Link that is its upper-case equivalent. If you created directory a
, then create symlink A
that points to a
so that both ls ln/a
and ls ln/A
give identical results. (You must use symbolic links, because you cannot make hard links to directories.)
In every file you have just created in this section, enter the following information, one name per line: Enter the names of the three common file system commands that are “directory only” commands that require permission only on the directory inode to work properly, and that do not require permissions on the file inode to work. The answer is three lines, one command name per line. (See your in-class notes for the three names I wrote on the board, or read the course notes about links and inodes.) The right answer has this format (three lines; three words; nine characters):
$ wc abcd0001.txt
3 3 9 abcd0001.txt
Again, the text abcd0001
must be your own userid, in all cases.
Hints: All the file names you created in this section should be hard links to the same file; you have very little editing to do. The three command names are all commands that are directory operations that manipulate file names; they don’t touch the file data and don’t need any permissions on the file data.
Use your symbolic link ./check
(created in the previous task) to run Checking Program to verify your work so far.
That is all the tasks you need to do.
Check your work a final time using your symbolic link to 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 as a command name:
~idallen/cst8207/14f/assignment06/assignment06check
You learn one way to make this name shorter in one of the tasks of this assignment.
Execute the above check
program as a command line on the CLS. 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 Base Directory on the CLS. Use that exact name. Case (upper/lower case letters) matters. Be absolutely accurate, as if your marks depended on it.
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
assignment06.txt
file from your local computer to the correct Assignment area on Blackboard (with the exact name) before the due date:
Use only Attach File on the Upload Assignment page. Do not enter any text into the Text 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 revise and upload the file more than once using the Start New button on the Review Submission History page to open a new Upload Assignment page. I only look at the most recent submission.
You must upload the file with the correct name from your local computer; 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 can use the Start New button on this page to re-upload your assignment as many times as you like.
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 Linux-format plain text, not HTML, not RTF, not MSWord. No fonts, no word-processing. Linux plain text only.
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!