% CST8207 Assignment 08 -- disk usage, hard and soft (symbolic) links % Ian! D. Allen -- -- [www.idallen.com] % Fall 2018 - September to December 2018 - Updated 2018-10-19 02:28 EDT - [Course Home Page] - [Course Outline] - [All Weeks] - [Plain Text] Due Date and Deliverables ========================= > **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. - **Due Date**: `23h59 (11:59pm) Friday November 2, 2018 (end of Week 9)` - You have more than one week to do this assignment, but your next assignment will be available soon and will overlap this assignment. Start work on this now! Don't delay! - Late assignments or wrong file names may not be marked. Please be accurate and punctual. - **Available online** - Version 1 -- 02:10 October 19, 2018 - **Prerequisites** - All [Class Notes][hyperlink URLs] since the beginning of term. - All your previous [Assignments] and [Worksheets]. - An ability to **READ ALL THE WORDS** to work effectively. - **Deliverables** 1. One plain text file uploaded to Brightspace according to the steps in the [Checking Program] section below. 2. Use [Remote Login] to connect to the [Course Linux Server] (**CLS**) and use commands in [The Unix/Linux Shell] to create directory structure and files for marking on the **CLS**.\ **Do not delete any assignment work from the CLS until after the term is over!** **WARNING:** Some inattentive students upload Assignment #8 into the Assignment #7 upload area. Don't make that mistake! Be exact. Purpose and Background ====================== This assignment is based on your weekly [Class Notes][All Weeks] and covers these topics: 1. Examine how hard links work with disk usage in an easy, medium, hard, and ugly set of exercises. 2. Create your own hard links and soft (symbolic) links. How to complete this Assignment =============================== For full marks, follow these directions exactly: 1. These tasks must be done in your account via [Remote Login] to the [Course Linux Server]. 2. Do the tasks in order, from top to bottom. Do not skip steps. Most tasks are independent, but some depend on successful completion of a previous task. 3. **READ ALL THE WORDS** in each task before you begin the task, especially all the **Hints** and links. 4. Verify your own work before running the **Checking Program**. You won't have a checking program at your job interview and the **Checking Program** is not guaranteed to check everything. 5. Run the **Checking Program** at the end of the task to grade your work and help you find some of your errors. A perfect mark from the **Checking Program** does *not* mean your answers are correct. 6. When you are done with this Assignment, submit the output of the **Checking Program** to Brightspace before the due date, following the directions given at the end of this Assignment. Notes on doing assignment work ------------------------------ 1. You can use the **Checking Program** to check your work **after** you have completed each task. Most task sections below require you to **finish the whole task section before running the Checking Program**. You may not always be able to run the **Checking Program** successfully in the middle of a task or after every single task sub-step. The assignment tells you where you can safely check your work. 2. You will create file system structure in your CLS home directory containing various directories and files. When you are finished the tasks, leave the files and directories in place on the CLS as part of your deliverables for your instructor to verify. 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. **Do not delete any assignment work until after the term is over!** 3. You can modify your work and check it with the **Checking Program** as often as you like before you submit your final mark to Brightspace. You can upload your marks to Brightspace as many times as you like before the due date. Partial marks are accepted. 4. Your instructor will also mark on the due date the work you do in your account on the CLS. Leave all your work on the CLS and do not modify it after you have submitted your final mark to Brightspace. 5. You must keep a list of command names used each week and write down what each command does, as described in the [List of Commands You Should Know]. Without that list to remind you what command names to use, you will find future assignments very difficult. Searching the course notes on the CLS ------------------------------------- All course notes are available on the Internet and also on the CLS. You can learn about how to read and search these CLS files using the command line on the CLS under the heading *Copies of the CST8207 course notes* near the bottom of the page [Course Linux Server]. You also learned how to search the notes in [Assignment #05 HTML]. Draw File System Diagrams ------------------------- Many students find it extremely helpful to draw a quick graph/picture of their file system directory structure on paper before attempting to answer questions about relative pathnames. You need to be able to visualize the relative locations of names in the file system tree to answer these questions. Draw the trees on paper! - [File System Drawing V1] - [File System Drawing V2] - [File System Drawing V3] The Source Directory -------------------- All references to the **Source Directory** below are to the CLS directory `~idallen/cst8207/18f/assignment08/` and that name starts with a *tilde* character `~` followed by a user name 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. Tasks ===== Have you completed all the prerequisites, before attempting these tasks? Set Up -- The Base Directory on the CLS --------------------------------------- 1. 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. **All work in this assignment must be done on the CLS.** 2. Create the `assignment08` directory in your usual `Assignments` directory. **This `assignment08` directory is called the [Base Directory] for most pathnames in this assignment. Store your files and answers in this [Base Directory], not in your HOME directory or anywhere else.** **Hints:** See your previous assignment for hints on doing the above. Run the [Checking Program] to verify your work so far. Four Disk Usage Exercises: easy, medium, hard, ug1y --------------------------------------------------- You need to understand [Hard Links] and [Disk Usage] to do this task. **Read this task all the way through, especially the *Hints*, before you delete anything, or else you will have to start over again.** 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). ### `My DiskUse` 1. After you have run the [Checking Program] at least once, you will find created for you in the [Source Directory] a disk usage directory named `DiskUse/`*abcd0001* (where *abcd0001* is replaced by *your own userid*). Copy, using the *archive* option, this directory into your [Base Directory] using the name `My DiskUse`. (Do not create the `My DiskUse` directory before you do the *archive* copy or else you will create an extra level of directory.) **Verification of the copy:** > You will know you did the copy correctly if your personal copy of the > `My DiskUse` directory has the same disk usage summary value > (`du -s`) as the one in the [Source Directory] and there must be a > sub-directory named `My DiskUse/e/dir` with two hard-linked file > names in it. > > If there are no hard links anywhere, you didn't copy using the *archive* > option that preserves hard links. Delete everything and re-copy. > > A recursive list of pathnames under `My DiskUse` should count 478 > names. > > The `My DiskUse` directory should contain about fifty > sub-directories, each of which may contain one or more files and further > sub-sub-directories. (If you don't see almost three dozen sub-directories > under your copy of `My DiskUse`, read all the words in the **Hints** > again, below.) In your personal `My DiskUse` directory, many of the files are hard links to each other -- multiple names for the same file inode. There are four levels of difficulty in this task, one for each of four specially-named sub-directories in your personal `My DiskUse` directory. Do the **easy** level first, followed by the **medium** level, followed by the **hard** level, followed by the **ug1y** level. **Read this task all the way through, especially the *Hints*, before you delete anything, or else you will have to start over again.** ### The easy level and the three steps A B C 2. Locate the sub-directory of your personal `My DiskUse` directory that contains the text `easy` in the name. Make this your current directory and then follow steps **A** through **C** below: A. Under the current directory, there is a directory named `dir`. Make sure this is true before your continue. B. Reclaim all the disk space used by the files under `dir` by removing all the files under `dir` and any hard links to those files. Some of those hard links may be names in other sub-directories under the current directory; you don't have to scan the whole file system to find the hard links. Read the **Hints** carefully before you remove anything. C. Run the [Checking Program] to verify your work so far. See the **Hints** if you need to start over. ### The medium level 3. Locate the sub-directory of your personal `My DiskUse` directory that contains the text `medium` in the name. Make this your current directory. Repeat the steps **A** through **C** above. ### The hard level 4. Locate the sub-directory of your personal `My DiskUse` directory that contains the text `hard` in the name. Make this your current directory. Repeat the steps **A** through **C** above. ### The ug1y level 5. Locate the sub-directory of your personal `My DiskUse` directory that contains the text `ug1y` in the name. (Note carefully the strange spelling, which is *not* the same as `ugly`.) Make this your current directory. Repeat the steps **A** through **C** above. ### Hints for each level: easy, medium, hard, ug1y > ``{=html}**Hints:** The current directory must be set as given above > for each level.``{=html} > > 1. **Do not remove any names from `dir` until you also know how to find > and remove all the other names for these files.** Once you have removed > all the files from `dir`, it is too late to try to find out which other > names were hard links to the files in `dir`. > > 2. One or more of the files in the `dir` subdirectory have more than one > name. Some of those other names may be located in other subdirectories > somewhere under the current level. (You don't have to search the whole > disk partition to find them.) The disk blocks for these files in `dir` > will not be freed until you find and remove *all* their names. You will > need to look at inode numbers to know which files in directory `dir` > are also named in the other directories. You read about how to do this > in [Disk Usage]. > > 3. Options to `ls` to display hidden names and nongraphic (unprintable) > characters will be needed for the harder sections (RTFM). Many names > will need to be quoted to hide shell metacharacters (see [Quoting]). > > 4. If you don't get the right answer for a difficulty level, you can start > over by re-copying all or part of your `My DiskUse` directory > from where you originally got it in 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 one 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 `My 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. > > 5. If you find that you don't own any of the files under your > `My DiskUse` directory, and that you have no permission to remove > any files, then you didn't **copy** the files correctly. Delete > everything and re-read and re-do that first step. > > 6. **Do not remove any names from `dir` until you also know how to find > and remove all the other names for these files.** Once you have removed > all the files from `dir`, it is too late to try to find out which other > names were hard links to the files in `dir`. Symlink to the Checking Program ------------------------------- You need to understand [Symbolic Links] to do this task. ### `check` 1. Create a symbolic link named `check` in your [Base Directory] that links to the [Checking Program] in the [Source Directory]. You may use either an absolute or relative symlink. Now, 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. When in your [Base Directory] you can use your symbolic link `./check` to run [Checking Program] to verify your work so far. > You already created symbolic links to `oldnotes` and `newnotes` 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. Use your symbolic link `./check` to run [Checking Program] to verify your work so far. You may want to create a similar symlink when you do your future assignments. Hard and Soft Linking exercise ------------------------------ You need to understand [Hard Links] and [Symbolic Links] and to do this task. ### `linkDir1/`*abcd0001*`.txt` 1. In your [Base Directory], create a sub-directory and an empty file `linkDir1/`*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 `linkDir1` (seven letters and one digit). 2. For every unique character in your own eight-character userid, create a sub-sub-directory under `linkDir1` with that single-character name, with letters made upper-case. For example, the userid *abca0151* would result in six unique sub-sub-directory names under the `linkDir1` directory -- one sub-sub-directory for each of the unique characters `A`, `B`, `C`, `0`, `1`, `5`. Each new directory must be directly under the `linkDir1` directory. *(Note: 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. Use upper-case directory names. 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 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. 4. For every upper-case letter directory name you created, create a short, relative [Symbolic Link][Symbolic Links] that is its lower-case equivalent. If you created directory `A`, then create symlink `a` that points to (has a target of) `A` so that both `ls linkDir1/a` and `ls linkDir1/A` give identical results. (You must use symbolic links, because you cannot make hard links to directories.) 5. In every unique 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. The right answer has a word count of `3 3 9`. > **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 common commands that are [directory > operations][Hard Links] that manipulate file names; they don't touch the > file data and don't need any permissions on the file data. See your > in-class notes for the three names I wrote on the board, or re-read the > course notes about links and inodes. Use your symbolic link `./check` to run [Checking Program] to verify your work so far. When you are done ----------------- That is all the tasks you need to do. Check your work a final time using the [Checking Program] below and save the standard output of that program into a file as described below. Submit that file (and only that one file) to Brightspace following the directions below. Your instructor will also mark the [Base Directory] in your account on the due date. Leave everything there on the CLS. Do not delete anything. When you are done, log out of the CLS before you close your laptop or close the PuTTY window, by using the shell `exit` command: $ exit Nothing seriously bad will happen if you forget to log out, but you may leave behind an empty, "ghost" login session that may take some days to time out and disappear. Always `exit` before you close your laptop, PuTTY, or Terminal session. 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 single file that is the output of the **Checking Program** to Brightspace. > 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 `assignment08check` 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/18f/assignment08/assignment08check You learn one way to make this path shorter in this assignment. 2. When you are done, execute the above **Checking 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 run the **Checking Program** as many times as you wish, allowing you to correct mistakes and get the best assignment 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 this assignment, and you like the mark displayed on your screen by the **Checking Program**, you must **redirect** only the standard output of the **Checking Program** into the text file `assignment08.txt` in your [Base Directory] on the CLS, like this: $ ~idallen/cst8207/18f/assignment08/assignment08check >assignment08.txt - Use standard output redirection with that *exact* `assignment08.txt` file name. - Use that *exact* name. Case (upper/lower case letters) matters. - Be absolutely accurate, as if your marks depended on it. - Do not edit the output file; the format is fixed. You can view the output file one-page-at-a-time using the `less` program (use the space bar to page forward and use the letter `q` to quit): $ less assignment08.txt - In `less` use the space bar to page forward and use the letter `q` to quit). - Make sure the file actually contains the output of the **Checking Program**! - The file should contain, near the bottom, a line starting with: `YOUR MARK for` - Really! **MAKE SURE THE FILE HAS YOUR MARKS IN IT!** 4. Transfer the above single file `assignment08.txt` (containing the output from the **Checking Program**) from the CLS to your local computer. - Refer to the [File Transfer] page for how to transfer the file. - Verify that the file still contains all the output from the **Checking Program**. - Do not edit or open and save this file on your local computer! Edited or damaged files will not be marked. Submit the file exactly as given. - The file should contain, near the bottom, a line starting with: `YOUR MARK for` - Really! **MAKE SURE THE FILE YOU UPLOAD HAS YOUR MARKS IN IT!** 5. Upload the single `assignment08.txt` file from your local computer to the correct **A-08 Assignment #08** area on Brightspace before the due date: - See [Assignment #01] for details on how to upload files to Brightspace. - Only upload the one file that is the standard output of the [Checking Program]. - Make sure the file has the correct `assignment08.txt` name. - Make sure you upload it to the right place, *not* into Assignment 6 or 7! 6. 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!** Notes: - I do not accept any assignment submissions by EMail. Use only the Brightspace *Upload* and *Submit* method. - Use the *exact* file name given above. Upload only one single file of output from the **Checking Program**. - 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 The Words. Don't make that mistake! Be exact. **READ ALL THE WORDS. OH PLEASE, PLEASE, PLEASE READ ALL THE WORDS!** -- | Ian! D. Allen, BA, MMath - 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 [www.idallen.com]: http://www.idallen.com/ [Course Home Page]: .. [Course Outline]: course_outline.pdf [All Weeks]: indexcgi.cgi [Plain Text]: assignment08.txt [hyperlink URLs]: indexcgi.cgi#Important_Notes__alphabetical_order_ [Assignments]: indexcgi.cgi#Assignments [Worksheets]: indexcgi.cgi#Worksheets__not_for_hand_in_ [Checking Program]: #checking-marking-and-submitting-your-work [Remote Login]: 110_remote_login.html [Course Linux Server]: 070_course_linux_server.html [The Unix/Linux Shell]: 120_shell_basics.html [List of Commands You Should Know]: 900_unix_command_list.html [Assignment #05 HTML]: assignment05.html [File System Drawing V1]: data/violett_file_system_drawing1.jpg [File System Drawing V2]: data/violett_file_system_drawing2.jpg [File System Drawing V3]: data/filesystemdiagram.png [Base Directory]: #set-up-the-base-directory-on-the-cls [Hard Links]: 455_links_and_inodes.html [Disk Usage]: 457_disk_usage.html [Source Directory]: #the-source-directory [Quoting]: 440_quotes.html [Symbolic Links]: 460_symbolic_links.html [Hard Link]: 450_file_system.html [File Transfer]: 015_file_transfer.html [Assignment #01]: assignment01.html [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/