% CST8207 Assignment 07 - hard links, disk usage, du % Ian! D. Allen - idallen@idallen.ca - www.idallen.com % Winter 2013 - January to April 2013 - Updated Wed May 8 21:04:29 EDT 2013 Due Date and Deliverables ========================= - **Due Date**: `11h00 (11am) Monday March 11, 2013 (start of Week 9)` - Late assignments or wrong file names may not be marked. Be accurate. - **Available online**: - Version 01: 08h00 Monday March 4, 2013 - **Prerequisites**: - The current [Class Notes] - an ability to **READ ALL THE WORDS** to work effectively - **Deliverables**: 1. One text file uploaded to Blackboard according to the steps in the [Checking Program] section below. 2. Directory structure created and left for marking on the [Course Linux Server] (**CLS**).\ **Do not delete any assignment work from the CLS until after the term is over!** **WARNING:** Some inattentive students upload Assignment #7 into the Assignment #6 upload area. Don’t make that mistake! Be exact. Purpose of this Assignment ========================== This assignment is based on your weekly [Class Notes]. 1. To understand and work with hard links, `du`, `find`, and disk quotas. a) An *Easy* task b) A *Medium* task c) A *Hard* task Remember to **READ ALL THE WORDS** to work effectively and not waste time. Introduction and Overview ========================= This is an overview of how you are expected to complete this assignment. Read all the words before you start working. Complete the [Tasks] listed below on the [Course Linux Server] (**CLS**). Check your work using the given examples. Run a [Checking Program] to verify your work after you have run your own tests. Submit the output of the checking script to Blackboard before the due date. You must understand hard links and know how to use the `find` and `du` commands to do this assignment. See the [Class Notes], especially all the notes dealing with the [File System], [Inodes and Links], and [Disk Usage]. 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 remove a file, you must remove all the names a file has. (The link count must go to zero.) Your job 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. The Source Directory -------------------- All references to the “Source Directory” below are to the directory `~idallen/cst8207/13w/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`. Tasks ===== - Do the following tasks in order, from top to bottom. - These tasks must be done in your account on the [Course Linux Server]. - **READ ALL THE WORDS!** and do not skip steps. Set Up ------ 1. 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-13W/ `-- Assignments `-- assignment07 2. Execute the [Checking Program] located in the [Source Directory]. The command will create a directory named `blocks` in your `assignment07` directory that will contain some sub-directories and files. If you make errors in this assignment, you can remove or rename the `blocks` directory and re-execute the above [Checking Program] to re-create the `blocks` directory for you and start over. If you remove the `blocks` directory, you will need to redo the whole assignment. If you rename the directory, you can salvage from the saved directory the parts of the assignment you have already done successfully. The first level of difficulty is “easy” --------------------------------------- There is a directory named `blocks/easy`. This easy subdirectory contains `236` blocks (recursive total for everything) and a `foo` subdirectory that contains `84` blocks of those `236` blocks. $ cd blocks/easy $ du -s . 236 . $ du -s foo 84 foo Read this section all the way through before you delete anything. **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. 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 using the [Set Up] steps, above. The next level of difficulty is “medium” ---------------------------------------- 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 using the [Set Up] steps, above. The next level of difficulty is “hard” -------------------------------------- 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 using the [Set Up] steps, above. When you are done ----------------- That is all the tasks you need to do. Verify your disk usage for each section and then mark your work by running the [Checking Program]. Checking, Marking, and Submitting your Work =========================================== **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. 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/13w/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 tasks 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. Use the *exact* name `assignment07.txt` in your `assignment07` directory. You only get *one* chance to get the name correct. Case (upper/lower case letters) matters. Be absolutely accurate, as if your marks depended on it. Do not edit the file. 4. Transfer the above `assignment07.txt` file from the CLS to your local computer and verify its contents. 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. 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 want to send me comments about your assignment, use email.) 6. Your instructor may also mark the `assignment07` 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!** -- | 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 [Checking Program]: #checking-marking-and-submitting-your-work [Course Linux Server]: 010_course_linux_server.html [Tasks]: #tasks [File System]: 450_file_system.html [Inodes and Links]: 455_links_and_inodes.html [Disk Usage]: 457_disk_usage.html [Source Directory]: #the-source-directory [Set Up]: #set-up [File Transfer]: 015_file_transfer.html [Plain Text]: assignment07.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/