% CST8207 Assignment 02 - Course Linux Server simple commands % Ian! D. Allen - - [www.idallen.com] % Winter 2014 - January to April 2014 - Updated Tue Apr 8 20:38:51 EDT 2014 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**: `10h00 (10am) Monday February 3, 2014 (start of Week 5)` - You have two weeks to do this assignment, but your next assignment will be available next week and will overlap this assignment by a week. Don’t delay! - Late assignments or wrong file names may not be marked. Please be punctual. - **Available online** - Version 1 – 07h00 Monday January 20, 2014 - Version 2 – 05h20 Thursday January 23, 2014 - New due date. - **Prerequisites** - All [Class Notes][hyperlink URLs] since the beginning of term. - All your previous [Assignments]. - 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 #2 into the Assignment #1 upload area. Don’t make that mistake! Be exact. Purpose of this Assignment ========================== > 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. Log in remotely and start using the [Course Linux Server] (**CLS**). 2. Learn how to do [File Transfer] between machines and notice the incompatibilities of text file formats; try Notepad vs. Wordpad on a text file copied from Linux to Windows. 3. Upgrade your [Course Linux Server] (**CLS**) password security. 4. Learn to [RTFM] and use the `less` pagination program. 5. Use LibreOffice to complete [Worksheet #02 ODT]. 6. Use LibreOffice to complete [Worksheet #03 ODT]. 7. Execute some simple Linux commands and generate some Linux output. 8. Find some files. Move some files. Copy some files. 9. Transfer and submit a file to Blackboard. 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. 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. > 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]. The Source Directory -------------------- All references to the “Source Directory” below are to the CLS directory `~idallen/cst8207/14w/assignment02/` 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. 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. - Your instructor will 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. - **Do not delete any assignment work from the CLS until after the course is over.** Worksheet and Prompt -------------------- These worksheets prepare you to do the numbered tasks listed below by executing commands via [Remote Login] to the [Course Linux Server]. You can download Libre Office (or Open Office) for Windows to edit the Worksheet `*.odt` files and save your answers. (Or you can print the PDF and write your answers on paper.) Do *not* use MSWord. Record and save all your worksheet answers for study and quizzes! 1. Use LibreOffice or OpenOffice to open, complete, and save: [Worksheet #02 ODT] - Do not use MSWord to open this file; it damages the file. - You must read the week’s [Class Notes] before you do the worksheet. - You will find it easier to write over the red underscores using “OVERWRITE” typing mode instead of the default “INSERT” mode. - Another way to fill in answers is to double-click to select the entire line of underscores and then simply type or paste to replace it. - Record and save all your worksheet answers for study and quizzes! - **Read All The Words** 2. Use LibreOffice or OpenOffice to open, complete, and save: [Worksheet #03 ODT] - See the notes above for the previous worksheet. 3. Using the `PS1` variable syntax shown in [Worksheet #02 HTML], set your prompt to include your user name, your computer name, and the **basename** of your current working directory. (See the definition of **basename** in the [Pathnames] class notes.) - Your prompt should look similar to this:   `[abcd0001@idallen-ubuntu ~]$` Set your prompt every time you log in to the CLS, so that the prompt changes to tell you you the **basename** of your current working directory. This is faster than typing `pwd` all the time! Security – Change your CLS password ----------------------------------- The CLS is on the public Internet; security is important. Choose your password carefully. Accounts that do not have their passwords changed before the due date of this assignment will be disabled. 1. Read on Wikipedia: [Guidelines for strong passwords] 2. Read this [XKCD comic on good passwords] 3. Now RTFM for the Unix command named `passwd` (note the odd spelling). *No* arguments or options are needed to this command to change your *own* password. The `passwd` command is also described in [Worksheet #02 HTML]. 4. Change your CLS password to one that is more secure than the one you were given. **Find a way to remember your new password.** If you forget your password, contact your Linux instructor to have it reset. Set Up – The Base Directory --------------------------- 1. 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. Spelling and capitalization must be exactly as shown: a. Create the `CST8207-14W` directory in your CLS HOME directory. b. Create the `Assignments` directory in the `CST8207-14W` directory. c. Create the `assignment02` directory in the `Assignments` directory. Note: You can create the entire directory tree above using *one* single command with one option and one pathname argument, as you did at the end of Section 4 in [Worksheet #02 HTML]. System administrators like to work efficiently – they learn how to do things quickly. You can check this directory tree by making your HOME directory your current directory and using one of these `tree` commands below. *Try both command lines below and use the command that gives the best-looking output in your terminal.* $ tree CST8207-14W $ tree -A CST8207-14W The correct output will look similar to the ASCII tree diagram below. The spelling and capitalization must be *exactly* as shown. CST8207-14W `-- Assignments `-- assignment02 **This `assignment02` directory is the *base* directory for most pathnames in this assignment. Store your files and answers below in this *base* `assignment02` directory.** Run the [Checking Program] to verify your work so far. Creating new files and directories ---------------------------------- > You may find it easier to type if you make the base directory you created > above (`assignment02`) your current directory for this section. 1. Copy the `cal.txt` file you created in [Assignment #01 HTML] into the base directory using the new name `calcopy.txt` for the file. The base directory now has one file in it (and nothing else). 2. Create the following directory structure in the base directory and record (for study purposes) the series of Unix commands you used to create it. Spelling and capitalization must be exactly as shown: a. The `mydir` directory is created in the base directory. b. Under directory `mydir` create two new directories named `one` and `two` (three letters each). c. Under directory `one` create new directory `oneone` (six letters). d. Under directory `two` create new directory `twotwo` (six letters). Note: You can create the entire directory tree above using *one* single command with one option and two pathname arguments, as you did at the end of Section 4 in [Worksheet #02 HTML]. System administrators like to work efficiently – they learn how to do things quickly. The correct directory tree under the base directory will look similar to the ASCII tree diagram below. The spelling and capitalization must be *exactly* as shown. mydir |-- one | `-- oneone `-- two `-- twotwo 3. Copy the directory `mydir` to new directory `mydir2` using the correct directory copy option, as you did in Section 3 of [Worksheet #03 HTML]. (`mydir2` should not exist before you do this! If it already exists, recursively remove it before you do the copy.) Verify that the tree structure of `mydir2` is exactly the same as the `mydir` directory from which you copied it. Run the [Checking Program] to verify your work so far. Generating a recursive pathname list ------------------------------------ 1. Make the base directory your current directory and then use a command to recursively generate a list of all pathnames under your `mydir` directory. (You used this recursive command many times in the last section at the end of [Worksheet #02 HTML]. Do not use the `tree` or `ls` commands. Use the `mydir` directory as your *starting directory*.) The recursive output of all pathnames under your `mydir` directory will be exactly five lines long and will contain this *exact* line in the output somewhere (along with another four lines): `mydir/one/oneone` Make sure the *exact* line above appears as one of the five lines! > Recall that you can redirect any output that appears on your screen into a > file by adding to the end of the command line a “greater than” angle > bracket (`>`) followed by a file name. (We did this using the `cal` command > to create the `cal.txt` file in the Week 1 lab.) 2. When the five lines of recursive output above on your screen looks correct, redirect the output of the command into the file named `paths.txt` in the `oneone` directory that you created earlier under the `mydir2` directory. (Use a relative path down to the `oneone` directory under `mydir2`, as shown in the lectures.) 3. Make the `oneone` directory under `mydir2` your current directory. (Make sure you get the right one under `mydir2`! Display your current working directory and make sure.) 4. Use a command to list the files in the current directory to confirm that the `paths.txt` file is here. Use another command to display the contents of the `paths.txt` file, and make sure it contains exactly five lines of pathnames from under the `mydir` directory. 5. From the `oneone` directory, copy the `paths.txt` file (from the current directory) into the `twotwo` directory that is also under the `mydir2` directory, giving it the new name `paths.txt.copy` as you copy it. Again, use relative paths to do the copy, as shown in the lectures. *(Hint: Draw a file system hierarchy picture to help you derive the correct relative pathname.)* 6. Use the `echo` command to echo into file `copycmd.txt` in the base directory the command line and two relative pathname arguments you used to make the above copy. The `copycmd.txt` file should contain on one line the copy command name followed by two relative pathname arguments, exactly as you typed it. (The `copycmd.txt` output file should be located in the base directory, not in the `oneone` directory, so you need to specify a redirection pathname that leads up several levels to the base directory.) Run the [Checking Program] to verify your work so far. Working with existing directories and files ------------------------------------------- 1. Execute this exact command line in your account on the CLS: `~idallen/cst8207/14w/assignment02/create` - There is a leading *tilde* character `~` directly in front of the account name `idallen`, indicating to the shell that the pathname starts with the HOME directory of `idallen` (seven letters). - The command will create a directory named `newdir` in your `assignment02` directory. It will contain some sub-directories and files. Verify that `newdir` has been created. - You can re-execute the above line to start over from scratch, if you make errors in this part of the assignment. - To know what files and directories have been created by the above command line, use a command that will recursively show all the files and directories under a starting directory. (You already used this command, above.) > All the following commands in this section apply to files and directories > under the new `newdir` directory. You will have to use commands to find > some of the file names mentioned here; they may be located under > sub-directories. (See [Searching and Finding Files].) Some of these tasks > may require more than one command to complete. 2. Find and read the file named `README.txt` (located somewhere under some directory under `newdir`). You have to find this file. 3. Read and then delete the file `foo.txt` that is in the same directory as the `README.txt` file. (Do not delete any other decoy files named `foo.txt` that may be in other directories.) 4. Move (rename) the file `dst` to be `dst.bak` (This is a *move*, not a *copy*. It renames the file.) 5. Directly under the `newdir` directory, create a new empty directory named `dst` (three letters). (Make sure you create `dst` under `newdir`, not in your HOME or any other directory.) 6. Find the *file* named `services` (not the directory with the same name) and move (rename) that `services` file to be named `ports` under the new directory `dst` that you just created. (This is a *move/rename*, not a *copy*.) Make sure you move the *file*, not the directory with the same name. Run the [Checking Program] to verify your work so far. Finding files in a maze ----------------------- 1. Under the [Source Directory] there is a directory named `maze` (four letters). (Recall that you do not have permission to list the names of all the files in the Source Directory, but you can access the `maze` directory there because you know its name.) This maze directory contains many hidden sub-directories. (You need a special option to see hidden files and directories.) In this maze, use a single command to recursively find the file with a 12-character **basename** that looks similar to *abcd0001.txt* but where the eight-character *abcd0001* part of the name is replaced by **your own account userid**. You must use a single command that finds files by **basename** to find this 12-character file name. Do not try to use `cd` and `ls` to find the file in the maze; the maze is very big. (You have previously used the command you will need here. Hint: Section 8 of [Worksheet #02 HTML].) 2. When you have found your personal `abcd0001.txt` file in the maze, create a new directory `treasure` under `assignment02` and copy your personal file into that new directory using the new name `myfile.txt` under your `treasure` directory. Read the file to make sure it’s the right one before and after you copy it into the `treasure` directory. Run the [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] and save the output as described below. Submit your mark following the directions below. 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 `assignment02check` in the [Source Directory] on the CLS. You can execute this program by typing its (long) pathname into the shell: `~idallen/cst8207/14w/assignment02/assignment02check` 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 `assignment02.txt` under your `assignment02` directory on the CLS. Use the *exact* name `assignment02.txt` in your `assignment02` 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! 4. Transfer the above `assignment02.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. 5. Submit the `assignment02.txt` file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the **assignment02** “Upload Assignment” facility in Blackboard: click on the underlined **assignment02** 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. Verify that your latest submission has the correct 16-character, lower-case file name attached to it beside the *Attached Files* heading. (The *Submission Field* and *Student Comments* headings must be **empty**; I do not read them.) You will also see the *Review Submission History* page any time you already have an assignment attempt uploaded and you click on the underlined **assignment02** 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!** - I do not accept any assignment submissions by email. Use only the Blackboard *Attach File*. No word processor documents. Plain Text only. - Use the *exact* file name given above. Upload only one single file of plain text, not HTML, not RTF, not MSWord. No fonts, no word-processing. Plain text only. - Did I mention that the format is plain text (VIM/Nano/Pico/Gedit or TextEdit 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 16-character, lower-case 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/ [hyperlink URLs]: indexcgi.cgi#XImportant_Notes__alphabetical_order_ [Assignments]: indexcgi.cgi#XAssignments [Checking Program]: #checking-marking-and-submitting-your-work [Course Linux Server]: 070_course_linux_server.html [File Transfer]: 015_file_transfer.html [RTFM]: 140_man_page_RTFM.html [Remote Login]: 110_remote_login.html [Worksheet #03 ODT]: worksheet03.odt [Pathnames]: 160_pathnames.html [Guidelines for strong passwords]: http://en.wikipedia.org/wiki/Password_strength#Guidelines_for_strong_passwords [XKCD comic on good passwords]: http://xkcd.com/936/ [Searching and Finding Files]: 180_finding_files.html [Source Directory]: #the-source-directory [email]: mailto:idallen@idallen.ca [Plain Text]: assignment02.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/