% CST8207 Assignment 02 - Course Linux Server [CLS] % Ian! D. Allen - idallen@idallen.ca - www.idallen.com % Winter 2013 - January to April 2013 - Updated Wed May 8 21:04:29 EDT 2013 Due Date and Deliverables ========================= - **Due Date**: `11h00 (11am) Monday February 4, 2013 (start of Week 5)` - **NEW DUE DATE** - Late assignments or wrong file names may not be marked. Be accurate. - **Available online**: - Version 01: Tuesday January 15, 2013 - Version 02: Sunday January 20 2013 - Version 03: Thursday January 24, 2013 - **Prerequisites**: - Week 2 lab work logging in to the [Course Linux Server] (**CLS**) and transferring files (e.g. using Windows **FileZilla**) - 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 ========================== 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. 3. Upgrade your [Course Linux Server] (**CLS**) password security. 4. Learn to [RTFM] and use the `less` pagination program. 5. Complete [Lab Worksheet #02 PDF]. 6. Execute some simple Linux commands and generate some Linux output. 7. Find some files. Move some files. Copy some files. 8. 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 what you will do in this assignment. Read all the words before you start working. In Week 2 you had a lab on how to log in to the CLS and transfer files. That preparation work is outlined, below. Complete the numbered [Tasks] listed below on the [Course Linux Server] (**CLS**). Run a [Checking Program] to verify your work as you finish each task. Submit your marks to Blackboard. 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 tasks 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. CLS Login and File Transfer Practice ==================================== In Week 2, you did the following practice in your lab period, in preparation for the assignment: 1. Log in to the [Course Linux Server] (**CLS**) using the terminal program appropriate to your operating system (e.g. use `PuTTY` on Windows). - get your special CLS password from your instructor - most system admin work is done via remote log-in - choose the log-in method applicable to your local operating system, e.g. use `PuTTY` for Windows. 2. Try some Linux commands on the CLS: - `$ date` - `$ who` - `$ ls` - `$ ls -la` - `$ figlet Hello World` - `$ toilet Hello World` - `$ toilet --gay Hello World` - `$ cal 9 1752` - What is wrong with this month? - Try using `cal` with the year your were born, e.g. `cal 1954` - on what day of the week were you born? 3. Redirect the output of a command into an output file using `>` and then display the contents of the file: - `$ cal 9 1752` - `$ cal 9 1752 >cal.txt` - `$ cat cal.txt` 4. Do a [File Transfer] between the your local machine and the CLS: - choose the transfer method applicable to your local operating system, e.g. use `Filezilla` for Windows. a) Create a file `file.txt` on Windows using Notepad b) Transfer the `file.txt` file to Linux c) View the file name and file content on Linux using these Linux commmands: - `$ ls` - `$ ls -l` - `$ cat file.txt` - `$ file file.txt` 5. Do a [File Transfer] between the CLS and your local machine: a) Create a file `cal.txt` on Linux using output redirection: - `$ cal 9 1752` - `$ cal 9 1752 >cal.txt` - `$ cat cal.txt` - `$ file cal.txt` b) Transfer the `cal.txt` file to Windows c) View the file on Windows using both Notepad and then Wordpad - note the problems with Linux line-endings under Notepad - Linux and Windows text files are not compatible! Tasks ===== - Do all this work logged in to your account on the CLS. - Do the following numbered tasks in order, from top to bottom. **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.** The Source Directory -------------------- All references to the “Source Directory” below are to the directory\ `~idallen/cst8207/13w/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`. Label all your hardware ----------------------- 1. Put your name and contact information on all your books and hardware, including your external hard disks and power supplies. The name has to be clear enough that the office can contact you to give you back your hardware when you leave it behind somewhere. Worksheet and Prompt -------------------- This worksheet prepares you to do the numbered tasks listed below by executing commands while logged in remotely 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.) Save your answers for quizzes! 2. Use LibreOffice or OpenOffice to open, complete, and save: [Lab Worksheet #02 ODT] - Do not use MSWord to open this file; it damages the file. - 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. - Quizzes will ask you about your answers in your saved worksheets. - **Read All The Words** 3. Using the PS1 variable syntax shown in [Lab 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.) - The prompt will 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. 4. Read “Guidelines for strong passwords” in 5. Now read this XKCD comic: 6. Now RTFM for the Unix command named “`passwd`” (note the spelling). *No* arguments or options are needed to change your *own* password. The `passwd` command is also described in [Lab Worksheet #02 HTML]. 7. Change your 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. Creating new directories and files ---------------------------------- 8. 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 `-- assignment02 `-- tree |-- one | `-- oneone `-- two `-- twotwo - The “`CST8207-13W`” directory is created in your CLS HOME directory. - The “`Assignments`” directory is created in the `CST8207-13W` directory. - The “`assignment02`” directory is created in the `Assignments` directory. - The “`tree`” directory is created in the `assignment02` directory. - Under `tree` are two new directories named “`one`” and “`two`”. - Under directory `one` is new directory “`oneone`”. - Under directory `two` is new directory “`twotwo`”. You can check your work by making your HOME directory your current directory and using one of these commands below. Use the command that gives the best-looking output: $ tree CST8207-13W $ tree -A CST8207-13W The correct output will be similar to the ASCII tree diagram above. The spelling and capitalization must be exactly as shown. Note: You can create the entire directory tree above using one single command with one option and two pathname arguments. System administrators like to work efficiently - they learn how to do things quickly. 9. Make the `assignment02` directory your current directory and then use a command to recursively generate a list of all pathnames under your `tree` directory. (You used this command this at the end of [Lab Worksheet #02 HTML]). The recursive output of all pathnames under your `tree` directory will be exactly five lines long and will contain this exact line in the output somewhere (along with another four lines): `tree/one/oneone` * * * * * 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 2 labs and you can see an example of this up above in the [Practice] section.) * * * * * 10. When the 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. (Use a relative path down to the `oneone` directory, as shown in the Week 3 lectures.) 11. Make the `oneone` directory your current directory. 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 at least five lines of pathnames. 12. Copy the `paths.txt` file (from the current `oneone` directory) into the `twotwo` directory that you created earlier, giving it the new name “`paths.txt.copy`” as you copy it. Again, use relative paths to do the copy, as shown in the Week 3 lectures. *(Hint: Draw a file system hierarchy picture to help you derive the correct relative pathname.)* Run the [Checking Program] to verify your work so far. Working with existing directories and files ------------------------------------------- 13. Execute this exact command line in your account on the CLS: `$ ~idallen/cst8207/13w/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`. - The command will create a directory named “`stuff`” in your `assignment02` directory. It will contain some sub-directories and files. - 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 `stuff` 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. * * * * * 14. Find and read the file named “`README.txt`” (somewhere under `stuff`). 15. Read and then delete the file “`foo.txt`” that is in the same directory as “`README.txt`”. (Do not delete any other decoy files named “`foo.txt`” that may be in different directories.) 16. Move (rename) the file “`dst`” to be “`dst.bak`”. (This is a *move*, not a *copy*. It renames the file.) 17. Directly under the new “`stuff`” directory, create a new empty directory named “`dst`”. (Make sure you create “`dst`” under `stuff`, not in your HOME or any other directory.) 18. 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 ----------------------- 19. Under the [Source Directory] there is a directory named “`maze`”. This maze 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. 20. When you have found your personal “`abcd0001.txt`” file in the maze, copy your file into the “`dst`” directory you created above, using the new name “`me.txt`” under “`dst`”. Read the file to make sure it’s the right one after you copy it into “`dst`”. Run the [Checking Program] to verify your work so far. That is all the tasks you need to do. Next, mark your work: 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/13w/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. Use the *exact* name `assignment02.txt` in your `assignment02` 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 `assignment02.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 `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 want to send me comments about your assignment, use email.) 6. Your instructor may also mark the `assignment02` 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 [Course Linux Server]: 010_course_linux_server.html [Checking Program]: #checking-marking-and-submitting-your-work [File Transfer]: 015_file_transfer.html [RTFM]: 140_man_page_RTFM.html [Lab Worksheet #02 PDF]: worksheet02.pdf [Tasks]: #tasks [Lab Worksheet #02 ODT]: worksheet02.odt [Lab Worksheet #02 HTML]: worksheet02.html [Pathnames]: 160_pathnames.html [Practice]: #cls-login-and-file-transfer-practice [Searching and Finding Files]: 180_finding_files.html [Source Directory]: #the-source-directory [Plain Text]: assignment02.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/