Updated: 2014-03-09 17:12 EDT

1 Due Date and DeliverablesIndexup to index

Do not print this assignment on paper!

WARNING: Some inattentive students upload Assignment #7 into the Assignment #6 upload area. Don’t make that mistake! Be exact.

2 Purpose of this AssignmentIndexup to index

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.

  1. Work with your search $PATH.
  2. Create hard and soft (symbolic) links.
  3. Examine how hard links work with disk usage.
  4. Transfer and submit a file to Blackboard.

Remember to READ ALL THE WORDS to work effectively and not waste time.

3 Introduction and OverviewIndexup to index

This is an overview of how you are expected to complete this assignment. Read all the words before you start working.

  1. Complete the Tasks listed below.
  2. Verify your own work before running the Checking Program.
  3. Run the Checking Program to help you find errors.
  4. Submit the output of the Checking Program to Blackboard before the due date.
  5. READ ALL THE WORDS to work effectively and not waste time.

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, 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.

3.1 The Source DirectoryIndexup to index

All references to the “Source Directory” below are to the CLS directory ~idallen/cst8207/14w/assignment07/ 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.

4 TasksIndexup to index

4.1 Set Up – The Base DirectoryIndexup to index

  1. Do a Remote Login to the Course Linux Server (CLS) from any existing computer, using the name appropriate for whether you are on-campus or off-campus. All work in this assignment must be done on the CLS.

  2. Create the following directory structure starting in your CLS HOME directory and record (for study purposes) the series of Unix commands you used to create it. (You do not have to create any directories that you have already created in a previous assignment.) Spelling and capitalization must be exactly as shown:
    1. Create the CST8207-14W directory in your CLS HOME directory.
    2. Create the Assignments directory in the CST8207-14W directory.
    3. Create the assignment07 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
    `-- assignment07

This assignment07 directory is the base directory for most pathnames in this assignment. Store your files and answers below in this base assignment07 directory.

Run the Checking Program to verify your work so far.

4.2 Part I – Working with your search PATHIndexup to index

Create a file named check.sh under the base directory. Edit this file to contain exactly four lines of text:

  1. The first line must set the shell search PATH variable to include the Source Directory for this assignment appended at the (right) end of the path. Append to the existing PATH.
  2. The second line must safely echo the new value of PATH.
  3. The third line must run the date command.
  4. The fourth line must have the shell find and execute a command named assignment07check (which it will do using the modified PATH). 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.

Save your four-line shell script and run sh check.sh to execute your script. The script should display the modified PATH on your screen, then the date, 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.

Run the Checking Program to verify your work so far.

4.3 Part II – Linking exerciseIndexup to index

You need to understand Hard Links and Symbolic Links and to do this section.

  1. 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).

  2. 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.

  3. 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.

  4. 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.)

  5. 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, 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.

4.4 Part III – Disk Usage ExerciseIndexup to index

You need to understand Hard Links and Disk Usage to do this section.

Using the copy option that means archive that preserves hard links (as well as all the other attributes), recursively copy the directory named diskuse from the Source Directory to your base directory. You will know you got it right if your copy of the diskuse directory has the same disk use summary (du -s) as the one in the Source Directory.

The diskuse 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 diskuse directory and re-execute the above recursive copy command (with the archive option) to re-create the diskuse directory and start over.

This Part has three levels of difficulty. If you remove the entire diskuse 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.

4.4.1 The first level of difficulty is “easy”Indexup to index

There is a directory named easy under diskuse. 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 diskuse directory from the Source Directory.

Run the Checking Program to verify your work so far.

4.4.2 The next level of difficulty is “medium”Indexup to index

There are two hidden directory under diskuse. 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 diskuse directory from the Source Directory.

Run the Checking Program to verify your work so far.

4.4.3 The next level of difficulty is “hard”Indexup to index

There are two hidden directory under diskuse. 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 Quoting). 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 diskuse directory from the Source Directory.

Run the Checking Program to verify your work so far.

4.5 When you are doneIndexup to index

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.

5 Checking, Marking, and Submitting your WorkIndexup to index

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.

  1. There is a Checking Program named assignment07check in the Source Directory on the CLS. You can execute this program by typing its (long) pathname into the shell:

    $ ~idallen/cst8207/14w/assignment07/assignment07check

  2. 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.

  3. 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 assignment07.txt under your assignment07 directory on the CLS. Use the exact name assignment07.txt in your assignment07 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!
    • The last text line of the file should begin with: YOUR MARK for
    • Really! MAKE SURE THE FILE HAS YOUR MARKS IN IT!
  4. Transfer the above assignment07.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.
    • Make sure the file actually contains the output of the checking program!
    • The last text line of the file should begin with: YOUR MARK for
    • Really! MAKE SURE THE FILE HAS YOUR MARKS IN IT!
  5. Submit the assignment07.txt file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the assignment07 “Upload Assignment” facility in Blackboard: click on the underlined assignment07 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.

  6. Verify that Blackboard has received your submission: After using the Submit button, you will see a page titled Review Submission History that will show all your submissions.
    1. Verify that your latest submission has the correct 16-character, lower-case file name beside the Attached Files heading.
    2. The Submission Field and Student Comments headings must be empty. (I do not read them.)
    3. Save a screen capture showing the uploaded file name. If there is an upload missing, you will need this to prove that you uploaded the file.

    You will also see the Review Submission History page any time you already have an assignment attempt uploaded and you click on the underlined assignment07 link.

    You cannot delete an assignment attempt, but you can always upload a new version. I only mark the latest version.

  7. 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!

READ ALL THE WORDS. OH PLEASE, PLEASE, PLEASE READ ALL THE WORDS!

Author: 
| Ian! D. Allen  -  idallen@idallen.ca  -  Ottawa, Ontario, Canada
| Home Page: http://idallen.com/   Contact Improv: http://contactimprov.ca/
| College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/
| Defend digital freedom:  http://eff.org/  and have fun:  http://fools.ca/

Plain Text - plain text version of this page in Pandoc Markdown format

Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen