% CST8207 Assignment 08 -- setting permissions, mode, `umask`, web site image % Ian! D. Allen -- -- [www.idallen.com] % Winter 2017 - January to April 2017 - Updated 2017-03-28 04:16 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) Monday March 27, 2017 (start of Week 11)` - You have three weeks to do this assignment. - Material in this assignment is **NOT** on the upcoming second midterm test. - Do not spend time doing this assignment (3%) at the expense of studying for your upcoming second midterm test (15%)! - Late assignments or wrong file names may not be marked. Please be accurate and punctual. - **Available online** - Version 1 -- 01:15 March 6, 2017 - Version 2 -- 03:30 March 21, 2017 -- set upper limit on JPG file size - Version 3 -- 03:50 March 28, 2017 -- require local Algonquin HTTP access - **Prerequisites** - Complete [Worksheet #08 PDF] to practice with [Permissions] and [Umask]. - 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 Blackboard 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 #08 into the Assignment #07 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. Practice with setting [Permissions]. 2. Practice setting [Umask]. 3. Create an Internet web site with your picture. As noted above in the **Prerequisites**, parts of this assignment come from your answers in [Worksheet #08 PDF]. 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 Blackboard 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 Blackboard. You can upload your marks to Blackboard 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 Blackboard. 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]. The Source Directory -------------------- All references to the **Source Directory** below are to the CLS directory `~idallen/cst8207/17w/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.** ### `check` 3. Create the `check` symbolic link needed to run the **Checking Program**, as you did in your last assignment and as described in the section [Checking Program] below. **Hints:** See your previous assignment for hints on doing the above. Use the symbolic link to run the [Checking Program] to verify your work so far. Part A: A file to record your permissions ----------------------------------------- You need to understand [Permissions] for this task. 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 in the next Part below, or you can record all of the permissions after you have finished the Part below, before you run the **Checking Program**. You will need to complete the next Part, below, before you can finish recording all the permissions in this Part. The two Parts go together. ### *abcd0001.txt* 1. Copy the file `record.txt` from the [Source Directory] into your own file *abcd0001*`.txt` (no spaces) where the text *abcd0001* userid is replaced by your *own* eight-character userid in the file name. This file copy should be located directly under your [Base 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. > Note on the verb **edit**: To *edit* a file, you need to be able to *read* > the contents of the file, change the contents, and *write* them back into > the file. You do not need to execute the contents of the file unless you > are editing a script file. > > You will need to edit your copy of the file with a Linux command-line text > editor. [The VI Text Editor] is recommended, since that is the universal > text editor for system administrators. 3. Edit the *abcd0001.txt* file you just created and replace the entire `KEY:` line in the file with the output of running the [Checking Program] with a first argument of `-s` and a second argument that is the [*basename*] of the file you are editing, i.e. *abcd0001.txt* > **Hints on replacing the `KEY:` line in the file:** > > 1. First, run the [Checking Program] with the correct first and second > arguments: The first argument is `-s` and the second argument is your > *abcd0001.txt* [basename] file name. (Use your own userid in the > name, not *abcd0001*.) The correct `KEY:` output will be 1 line, 3 > words, and approximately 88 characters including the newline. The > correct output looks similar to this: > > `KEY:` > *abcd0001.txt =8/V3ETL3AjM4Q1UD9/MwATM/L2NwIDO0N3Y/THe05iY3AjM4Q3cj9vNyczN1YzN4QTMM* > > 2. Edit the new `KEY:` line into the *abcd0001.txt* file, replacing > just the `KEY:` line that is already in that file. Edit the > *abcd0001.txt* file and replace the `KEY:` line in that file with > your new `KEY:` line. > > - You could put the new `KEY:` output into a temporary file, and then > edit the *abcd0001.txt* file and read in that temporary file. > (You did this in VIM `vimtutor` Lesson 5.4. *RETRIEVING AND MERGING > FILES*.) > - You could append the new `KEY:` line to the bottom of the > *abcd0001.txt* file and then edit the file to delete the old > `KEY:` line and replace it with the new one that you appended to > the bottom of the file. (VIM makes moving lines easy.) > - You could also replace just the `KEY:` line using the VIM `!!` > method from section 2.1 #10 in [Worksheet #06 PDF]. (This is my > favourite method; this is how I would do it.) > - You could copy-and-paste the new `KEY:` line into your editor, > replacing just the old `KEY:` line in the file. Run the [Checking Program] to verify your work so far. 4. As you work on Creating Structure below, continue to edit the file and *replace* each string of three underscore characters "`___`" in the file with the correct three-digit numeric (octal) permission value that you use in the next Part below. Be careful not to make other accidental changes to 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. - The original file and the edited file must have identical word counts. - The three underscores at the end of each of the 13 lines must be replaced with three octal digits. - If you damage the file, using `diff` between the original and your edited version will be helpful in knowing what you changed. Part B: Creating structure with permissions ------------------------------------------- You need to understand [Permissions] for this task. Do the permissions section of [Worksheet #08 PDF] 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, after you have created all the structure. > > 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.** Create this set of directories and files, and set the permissions as given. Make sure you create directories where directories are required and files where files are required. ### `head` 1. Create a directory named `head` under your [Base Directory]: a) Directory `head` allows the group to use `ls` to see the content, but the group cannot create files or `cd` into the directory. The user has full permissions. Others have permission to access files if they know their names, but no permission to see or change the names. Record the permissions for `head` in the Record file. b) Are you remembering to create all the structure before you change any of the permissions? Read All The Words, above. ### `oaa bbb ccc` 2. Underneath directory `head` create three three-letter *directories* named: `oaa bbb ccc` a) Directory `oaa` has no permissions for user or group. Others have full permissions. Record the permissions. b) Directory `bbb` 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. c) Directory `ccc` 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. ### `ba bb bc` 3. Underneath directory `bbb` create three two-letter *files* named: `ba bb bc` a) None of the files have any permissions for group or other. b) File `ba` has execute permission (only) for the user. Record the permissions. c) File `bb` has read permission (only) for the user. Record the permissions. d) File `bc` has write permission (only) for the user. Record the permissions. ### `ca cb cc` 4. Underneath directory `ccc` create three two-letter *files* named: `ca cb cc` a) None of the files have any permissions for user or other. b) File `ca` has read and execute permission (only) for the group. Record the permissions. c) File `cb` has read and write permission (only) for the group. Record the permissions. d) File `cc` has write and execute permission (only) for the group. Record the permissions. ### `aaa *** ???` 5. Underneath directory `oaa` create three three-character *files* named: `aaa *** ???` *(Some characters are meta-characters that are special to the shell and will need careful handling. Review [Quoting].)* a) None of the files have any permissions for user or group. b) File `aaa` has full permissions for other. Record the permissions. c) File `***` has only write permission for other. Record the permissions. d) File `???` has no permissions 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. Run the [Checking Program] to verify your work so far. Part C: Minimal Permissions --------------------------- You need to understand [Permissions] for this task. Do the permissions section of [Worksheet #08 PDF] before continuing. Record all your answers for later quizzes. ### `minperms.txt` 1. Copy the file `minperms.txt` from the [Source Directory] into your [Base Directory]. 2. Fix the permissions on the file so that only you and your group can edit it. (See the **Hints** about the **edit** verb in Part A.) 3. Edit the file you just created and replace the entire `KEY:` line in the file with the output of running the [Checking Program] with a first argument of `-s` and a second argument that is the [*basename*] of the file you are editing, i.e. `minperms.txt` (To do this, review the `KEY:` **Hints** from Part A.) Run the [Checking Program] to verify your work so far. 4. Edit the file and replace *all* the sets of three underscore characters "`_`" with your answers from [Worksheet #08 PDF]. Missing permissions should be given as dashes so that each set of three underscores is replaced with exactly three other characters, e.g. replace `___` with `-w-` not with `-w` or `w`. Be careful not to make other accidental changes to 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. - The original file and the edited file must have identical word counts. - Every set of three underscores must be replaced with three permissions characters, as explained in the [Summary of `rwx` permissions]. - If you damage the file, using `diff` between the original and your edited version will be helpful in knowing what you changed. Run the [Checking Program] to verify your work so far. Part D: Using `umask` to mask default permissions ------------------------------------------------- You need to understand [Umask] for this task. Do the `umask` section of [Worksheet #08 PDF] before continuing. Record all your answers for later quizzes. ### `umaskfil.txt` 1. Copy the file `umaskfil.txt` from the [Source Directory] into your [Base Directory]. 2. Fix the permissions on the file so that you can edit it and your group and others can only read it. 3. Edit the file you just created and replace the entire `KEY:` line in the file with the output of running the [Checking Program] with a first argument of `-s` and a second argument that is the [*basename*] of the file you are editing, i.e. `umaskfil.txt` (To do this, review the `KEY:` **Hints** from Part A.) Run the [Checking Program] to verify your work so far. 4. Edit the file and replace *all* the sets of three underscore characters "`_`" with the correct three-digit `umask` value that would result in each set of symbolic permissions for a new directory. (Optionally check your work by setting your `umask` to the above value and then creating and examining the permissions of a new directory.) Be careful not to make other accidental changes to 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. - The original file and the edited file must have identical word counts. - The three underscores at the end of each of the nine lines must be replaced with three octal digits. - If you damage the file, using `diff` between the original and your edited version will be helpful in knowing what you changed. - Do *not* leave your `umask` set incorrectly after this exercise. Run the [Checking Program] to verify your work so far. Part E: Setting up your web site and picture -------------------------------------------- ### `public_html` ### `index.html` ### `me.jpg` Create a web page and upload your picture, following the directions in [Student Web Site and Picture]. After following those directions: 1. You must have a JPEG format image of yourself of the correct size stored in the file `me.jpg` in your `public_html` directory. 2. You must have an `index.html` index file. 3. If you have turned on optional Access Controls in your `.htaccess` file, then you must allow access from localhost `127.` so that your instructor can test your web site. Follow the given directions for the size and dimensions of the image file. If you use optional Access Controls, make sure that your web site is accessible to `127.` (localhost). Run the [Checking Program] to verify your work so far. When you are done ----------------- That is all the tasks you need to do. Read your CLS Linux EMail and remove any messages that may be waiting. See [Reading EMail] for help. 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 Blackboard 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 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 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**. ### `check` 1. There is a **Checking Program** named `assignment08check` in the [Source Directory] on the CLS. Create a symbolic link named `check` in your [Base Directory] that links to the above [Checking Program] in the [Source Directory], as you did in a previous assignment. 2. Execute the above **Checking Program** as a command line on the CLS. The checking program will check your work, assign you a mark, and display the output on your screen: $ ./check | less If the **Checking Program** is not yet ready, it will say `NOT FINISHED YET` and `DO NOT SUBMIT THIS FILE`. No mark is shown; do not submit the file. Wait until the checking program is finished (it gives you a mark) before you save and submit your marks. You may run the **Checking Program** as many times as you wish, allowing you 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 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: $ ./check >assignment08.txt $ less 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. - 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. - You may want to 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 `assignment08.txt` file from your local computer to the correct Assignment area on Blackboard (with the exact name) before the due date: 1. On your local computer use a web browser to log in to Blackboard and go to the Blackboard page for this course. 2. Go to the Blackboard *Assignments* area for the course, in the left side-bar menu, and under there find **assignment08** 3. Under *Assignments*, click on the underlined **assignment08** link for this assignment. a) If this is your first upload, the *Upload Assignment* page will open directly; skip the next sentence. b) If you have already uploaded previously, the *Review Submission History* page will be open and you must use the *Start New* button at the bottom of the page to get to the *Upload Assignment* page. 4. On the *Upload Assignment* page, scroll down and beside *Attach File* use *Browse My Computer* to find and attach your `assignment08.txt` file from your local computer. Make sure the assignment file has the correct name on your local computer before you attach it. Attach *only* your `assignment08.txt` file for upload. Do not attach any other file names. 5. After you have attached the `assignment08.txt` file on the *Upload Assignment* page, scroll down to the bottom of the page and use the *Submit* button to actually upload your attached `assignment08.txt` file to Blackboard. 6. Submit the file exactly as uploaded from the CLS. 7. Do not submit an empty file. Do not submit any other file names. **Make sure the file name on Blackboard is correct!** Use only *Attach File, Browse My Computer* on the *Upload Assignment* page. Do not enter any text into the *Write Submission* or *Add Comments* boxes on Blackboard; I do not read them. Use only the *Attach File, Browse My Computer* section followed by the *Submit* button. If you need to comment on any assignment submission, send me [EMail]. You can revise and upload the file more than once using the *Start New* button on the *Review Submission History* page to open a new *Upload Assignment* page. I only look at the most recent submission. You must upload the file with the correct name from your local computer; you cannot correct the name as you upload it to Blackboard. **Make sure the file name on Blackboard is correct!** 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 uploaded submissions for this assignment. Each of your submissions is called an *Attempt* on this page. A drop-down list of all your attempts is available. a) Verify that your latest *Attempt* has the correct 16-character, lower-case file name under the *SUBMISSION* heading. b) The one file name must be the *only* thing under the *SUBMISSION* heading. Only the one file name is allowed. c) No *COMMENTS* heading should be visible on the page. Do not enter any comments when you upload an assignment. d) Click on the *Download* button to open and view the file you just uploaded. **MAKE SURE THE FILE YOU JUST UPLOADED HAS YOUR MARKS IN IT!** e) **Save a screen capture** of the *Review Submission History* page on your local computer, showing the single uploaded file name listed under *SUBMISSION*. If you want to claim that you uploaded the file and Blackboard lost it, you will need this screen capture to prove that you actually uploaded the file. (To date, Blackboard has never lost an uploaded file.) f) Make sure you have used *Submit* and not *Save as Draft*. I cannot mark draft assignments. Make sure you *Submit*. You will also see the *Review Submission History* page any time you already have an assignment attempt uploaded and you click on the underlined **assignment08** link. You can use the *Start New* button on this page to re-upload your assignment as many times as you like. 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!** - I do not accept any assignment submissions by EMail. Use only the Blackboard *Attach File, Browse My Computer*. No word processor documents. Plain Text only. - Use the *exact* file name given above. Upload only one single file of Linux-format plain text, not HTML, not RTF, not MSWord. No fonts, no word-processing. Linux plain text only. - **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 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_ [Worksheet #08 PDF]: worksheet08.pdf [Permissions]: 500_permissions.html [Umask]: 510_umask.html [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 [Base Directory]: #set-up-the-base-directory-on-the-cls [Source Directory]: #the-source-directory [The VI Text Editor]: 300_vi_text_editor.html [*basename*]: 160_pathnames.html#definition-of-basename [basename]: 160_pathnames.html#definition-of-%20basename [Worksheet #06 PDF]: worksheet06.pdf [Quoting]: 440_quotes.html [Summary of `rwx` permissions]: 500_permissions.html#summary-of-rwx-permissions [Student Web Site and Picture]: 000_student_web_site.html [Reading EMail]: 630_crontab_at_job_scheduler.html#reading-email-from-cron-and-at-jobs [File Transfer]: 015_file_transfer.html [EMail]: mailto:idallen@idallen.ca [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/