% CST8207 Assignment 08 - quoting, linking, setting permissions % Ian! D. Allen -- -- [www.idallen.com] % Winter 2013 - January to April 2013 - Updated 2017-05-31 12:12 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**: `11h00 (11am) Friday March 22, 2013 (end of Week 10)` - Late assignments or wrong file names may not be marked. Be accurate. - **Available online**: - Version 01: 03h00 Monday March 11, 2013 - Version 02: 18h00 Thursday March 14, 2013 (*NEW DUE DATE*) - **Prerequisites**: - The current [Class Notes][All Weeks] - [Lab Worksheet #08 ODT] - 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 #8 into the Assignment #7 upload area. Don't make that mistake! Be exact. Purpose of this Assignment ========================== This assignment is based on your weekly [Class Notes][All Weeks]. 1. Practice [Quoting] strings as command line arguments. 2. Practice creating [Hard Links] and [Symbolic Links] to files. 3. Practice with [Permissions] in [Lab Worksheet #08 ODT] 4. Practice creating structure and changing [Permissions]. 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. Edit a file to fix the [Quoting] to protect all shell meta-characters. Create some [Hard Links] and [Symbolic Links] to files. Create directory and file structure with the given [Permissions]. Record the numeric (octal) permissions of each of the directories and files you create in the given record file. The Source Directory -------------------- All references to the "Source Directory" below are to the directory `~idallen/cst8207/13w/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`. 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 `-- assignment08 **This directory is the base directory for most pathnames in this assignment. Store your scripts and answers here.** 2. There is a [Checking Program] named `assignment08check` in the [Source Directory] on the CLS. Follow the instructions in the first two steps at the start of [Checking Program] to create a working symbolic link to this program. Part A - Quoting exercise ------------------------- 1. Copy the script file `test.sh` from the [Source Directory] into your own file `test.sh`. 2. Fix the [Permissions] on the file so that you can edit it and execute it and nobody else (group or other) has any permissions at all. 3. Execute this script file and note that the output doesn't match what is written in the file. Fix the [Quoting] inside the file so that every line appears exactly as written, blanks included, with no meta-character expansion by the shell. The correct output should give eight lines and look like this when you are finished: Where is the question mark after the file /etc/passwd? Is one also missing after /etc/group? The shell prompt is contained in the $PS1 variable. This isn't appearing on my screen properly. It's missing some quotes. This is also "missing" some 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. *** The entire line of text on each line must be made into exactly *one* argument to `echo`. You can check your success by temporarily substituting the `argv` program from the [Class Notes][All Weeks] for the `echo` command. (You have to put the `argv.sh` program into the current directory under the name `argv.sh` and make it executable. Read the `test.sh` file for details on using this program. Remember to return the script to using only `echo` after your testing.) You'll know you got it mostly right when you see this `wc` and `sum` output (but you'll need to verify *one-argument-per-echo* using the `argv.sh` program): $ ./test.sh | wc 8 77 461 $ ./test.sh | sum 39169 1 If your 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. 4. Run the script and redirect the output into file `testout.txt` Part B - Linking exercise ------------------------- 1. 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). 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`. 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][Hard Links] 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][Symbolic Links] 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, 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 7 and Week 8.) 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. Hint: All the file names you created in this Part should be hard links to the same file. Part C - A file to record your permissions ------------------------------------------ You need to record the [Permissions] you set on each of the directories and files you create in the next Part, below. You will record these permissions by copying and editing a file that you get from your instructor. You can record each of the permissions as you create things step-by-step below, or you can record all of the permissions after you have finished, before you run the checking program. 1. Copy the file `record.txt` from the [Source Directory] into your own file *abcd0001*`.txt` (no spaces) where the text *abcd0001* is replaced by your *own* eight-character userid in the file name. This file copy should be located directly under your `assignment08` directory. 2. Fix the [Permissions] on the file so that you can edit it and nobody else (group or other) has any permissions at all. 3. As you work on the next Part below, edit your copy of the file with `vim`. *Replace* each string of three underscores in the file with the correct three-digit numeric (octal) permission value that you record in the next Part below. Do not change anything else in the file. Note the word count at the bottom of the file. Your count must match exactly, at all times. If not, re-copy the file and start over. Part D - Creating structure with permissions -------------------------------------------- Do the [Permissions] section of [Lab Worksheet #08 ODT] before continuing. Record all your answers for later quizzes. Now you will create some directories and files, then set the correct permissions on them. The permissions to set are described below. Because you are applying [Permissions] to directories as a non-root user, be careful not to lock yourself out of directories by restricting permissions on them too soon. First, create all the file and directory structure from the top of the directory tree down, and then apply restrictive permissions afterward from the bottom of the tree upward. If you don't apply permissions last, from the bottom up, you will deny yourself permissions that will prevent you from entering some directories lower down. Assign permissions from the bottom toward the top. 1. Create a directory named `head` under `assignment08` a) Directory `head` has no permissions for others. The group can use `ls` to see the content, but cannot create files or `cd` into the directory. The user has full permissions. Record the permissions for `head` in the Record file. 2. Underneath directory `head` create three three-letter directories named: `usr grp oth` a) Directory `usr` has no permissions for group or other. The user can `cd` into it, but cannot create any new content nor use `ls` to see any files in it. Record the permissions. b) Directory `grp` has no permissions for user or other. The group can `cd` into it and use `ls` in it, but cannot create any new content. Record the permissions. c) Directory `oth` has no permissions for user or group. Others have full permissions. Record the permissions. 3. Underneath directory `usr` create three two-letter *files* named: `rd wr xc` (You did create *files*, right?) a) None of the files have any permissions for group or other. b) File `rd` has read permission (only) for the user. Record the permissions. c) File `wr` has write permission (only) for the user. Record the permissions. d) File `xc` has execute permission (only) for the user. Record the permissions. 4. Underneath directory `grp` create three two-letter *files* named: `rw wx rx` a) None of the files have any permissions for user or other. b) File `rw` has read and write permission (only) for the group. Record the permissions. c) File `wx` has write and execute permission (only) for the group. Record the permissions. d) File `rx` has read and execute permission (only) for the group. Record the permissions. 5. Underneath directory `oth` create three three-character *files* named: `rwx ??? ***` *(Some characters are meta-characters that are special to the shell and will need careful handling. See the [Class Notes][All Weeks] about [Quoting].)* a) None of the files have any permissions for user or group. b) File `rwx` has full permissions for other. Record the permissions. c) File `???` has no permissions for other. Record the permissions. d) File `***` has only read permission for other. Record the permissions. Remember to read all the words above about working from top to bottom and then from bottom to top in this Part. When you are done ----------------- 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. Checking, Marking, and Submitting your Work =========================================== > 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]. Answer the questions according to the assignment, not > according to the incomplete set of mistakes detected by the [Checking > Program]. **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 `assignment08check` in the [Source Directory] on the CLS. Create a [Symbolic Link][Symbolic Links] to this program named `check` under your new `assignment08` directory so that you can easily run the program to check your work and assign your work a mark. Note: You can create a symbolic link to this executable program but you do not have permission to read or copy the program file. 2. Execute the above "check" program using its new symbolic link. (Review the [Search Path] notes if you forget how to run a program by pathname from the command line.) 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 `assignment08.txt` under your `assignment08` directory. Use the *exact* name `assignment08.txt` in your `assignment08` 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 `assignment08.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 `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.) 6. 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!** -- | 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 [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_ [Lab Worksheet #08 ODT]: worksheet08.odt [Checking Program]: #checking-marking-and-submitting-your-work [Course Linux Server]: 010_course_linux_server.html [Quoting]: 440_quotes.html [Hard Links]: 450_file_system.html [Symbolic Links]: 460_symbolic_links.html [Permissions]: 500_permissions.html [Tasks]: #tasks [Source Directory]: #the-source-directory [Search Path]: 400_search_path.html [File Transfer]: 015_file_transfer.html [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/