Updated: 2013-11-19 10:47 EST
08h00 (8am) Monday November 11, 2013 (start of Week 11)
WARNING: Some inattentive students upload Assignment #7 into the Assignment #6 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.
ln
, and disk use du
.PATH
so the shell can find a command name in a different directory.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 must understand hard links and know how to use the ln
, find
and du
commands to do this assignment. See the Class Notes, especially all the notes dealing with the File System, Inodes and Links, Disk Usage, and Symbolic Links.
Non-empty files occupy disk space. Hard links to files only occupy a little extra space in a directory for the extra file name; they don’t create new disk file space. To completely remove a file, you must remove all the names a file has. (The link count must go to zero.)
Your job in Part C of this assignment is to remove all the files in a directory and reduce the disk space used. You will be given a series of directories containing linked files. You have to remove all the names for some files so that the system actually frees up the disk space.
Recall that the rm
command does not remove files; it only removes names. Your job is to make the system remove the disk blocks occupied by the files, to make more disk space, which means you need to find and remove all the names for the files so that the link counts go to zero.
There are three levels of difficulty. Do the easy one first.
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.
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/assignment08/
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
`-- assignment08
Run the Checking Program to verify your work so far.
In your assignment08
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
.
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. 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 Part, 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 in Week 8, 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 Part 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.
Run the Checking Program to verify your work so far.
PATH
IndexCreate a file named check.sh
under your assignment08
directory. Edit this file to contain exactly three lines of text:
PATH
variable to include the Source Directory for this assignment appended at the (right) end of the path.echo
the new value of PATH
.assignment08check
(which it will do using the modified PATH
).Save your three-line shell script and run sh check.sh
to execute your script. The script should display the modified PATH
on your screen and then run the checking program for you. (This will only work if the shell search PATH
is set correctly in the file, otherwise it will say command not found
.)
Hints: You need to know how to append to PATH
. Remember to quote all variable expansions. The shell uses PATH
to find and run commands.
Using the copy option that means archive
that preserves hard links (as well as all the other attributes), recursively copy the directory named blocks
from the Source Directory to your assignment08
directory. You will know you got it right if your copy of the blocks
directory has the same disk use summary (du -s
) as the one in the Source Directory.
The blocks
directory contains three sub-directories and many other files and sub-directories. 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. Delete everything and re-copy.)
If you make errors in this assignment, you can remove or rename the blocks
directory and re-execute the above recursive copy command (with the archive
option) to re-create the blocks
directory and start over.
This Part has three levels of difficulty. If you remove the entire blocks
directory to start over, you will need to redo the all three levels. If you are smart and rename the directory, you can salvage from the saved directory the parts of the assignment you have already done successfully.
There are three levels of difficulty. Do the easy one first.
There is a directory named easy
under blocks
. This easy subdirectory contains 236
blocks (recursive total for everything) and a foo
subdirectory that contains 84
blocks of those 236
blocks:
$ du -s .
236 .
$ du -s foo
84 foo
Read this section all the way through before you delete anything, or else you will have to start over again.
YOUR JOB: Remove all the files in the foo
subdirectory (but keep the directory), so that the total disk use in the easy
directory drops to 236-80=156
blocks. Don’t try to do this until you’ve read this whole section through, including the Hints below.
Hints: Some of the files in the foo
subdirectory have more than one name. Those other names are located somewhere else under easy
. (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.
If you succeed in the easy
directory you will see this:
$ du -s . ; du -s foo ; find . | wc
156 .
4 foo
39 39 431
If you don’t get the right answer, you can start over by re-copying all or part of the blocks
directory from the Source Directory.
Run the Checking Program to verify your work so far.
There are two hidden directory under blocks
. One name contains the string medium
as part of its name. This medium subdirectory contains 368
disk blocks (recursive total for everything) and a foo
subdirectory that contains 132
of those 368
blocks.
YOUR JOB: Remove all the files in the foo
subdirectory (but keep the directory), so that the total disk use in the medium directory drops to 368-128=240
blocks.
Hints: See the previous question for hints on finding all the file names.
If you succeed in the medium directory you will see this:
$ du -s . ; du -s foo ; find . | wc
240 .
4 foo
60 60 744
If you don’t get the right answer, you can start over by re-copying all or part of the blocks
directory from the Source Directory.
Run the Checking Program to verify your work so far.
There are two hidden directory under blocks
. One name contains the string hard
as part of its name. This hard subdirectory contains 304
disk blocks (recursive total for everything) and a foo
subdirectory that contains 132
of those 304
disk blocks.
YOUR JOB: Remove all the files in the foo
subdirectory (but keep the directory), so that the total disk use in the hard directory drops to 304-128=176
blocks.
Hints: An option to ls
to display nongraphic (unprintable) characters will be needed. Many file names will need to be quoted to protect shell metacharacters. See the previous question for hints on finding all the file names.
If you succeed in the hard directory you will see this:
$ du -s . ; du -s foo ; find . | wc
176 .
4 foo
60 165 864
If you don’t get the right answer, you can start over by re-copying all or part of the blocks
directory from the Source Directory.
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.
There is a Checking Program named assignment08check
in the Source Directory on the CLS. You can execute this program by typing its (long) pathname into the shell:
$ ~idallen/cst8207/13f/assignment08/assignment08check
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.
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 assignment08.txt
under your assignment08
directory on the CLS. Use the exact name assignment08.txt
in your assignment08
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 assignment08.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 assignment08.txt
file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the assignment08 “Upload Assignment” facility in Blackboard: click on the underlined assignment08 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 assignment08
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!