% CST8207 Assignment 03 - basic commands % 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 11, 2013 (start of Week 6)` - Late assignments or wrong file names may not be marked. Be accurate. - **Available online**: - Version 01: Wednesday January 30, 2013 - Version 02: 05:30 Monday February 4, 2013 - **Prerequisites**: - Previous [Worksheet #2 HTML] - Previous [Assignment #2 HTML] - Current [Worksheet #3 HTML] - The current [Class Notes] - 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 #3 into the Assignment #2 upload area. Don’t make that mistake! Be exact. Purpose of this Assignment ========================== This assignment is based on your weekly [Class Notes]. 1. Complete [Lab Worksheet #03 ODT]. 2. Execute some simple Linux commands and generate some Linux output. 3. Find some files. Move some files. Copy some files. 4. 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. 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. 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/assignment03/`  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`. Worksheet and Prompt -------------------- 1. Do the [Lab Worksheet #03 ODT] before this assignment. Record all your answers for later quizzes. 2. 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! 3. RTFM and find the single-letter option to the copy program that preserves mode, ownership, and timestamps when you copy. You will need this, below. Working with directories and files ---------------------------------- 4. 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 `-- assignment03 `-- top1 |-- dir1 | `-- dir1-1 `-- dir2 `-- dir2-1 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. 5. Make the `top1` directory your current directory and then use a command to recursively generate a list of all pathnames under your *current directory*. The recursive output of all pathnames under your *current directory* will be exactly five lines long and will contain this **exact** line in the output somewhere (along with another four lines): `./dir2/dir2-1` Note that there is no punctuation at the end of any pathname. 6. When the recursive output above on your screen looks correct, redirect the five lines of output of the command into the file named “`top1find.txt`” in the `assignment03` directory (not in the current directory). The word count of this file must be: `5 5 44`. 7. Under `assignment03` create another directory `top2` that contains a copy of everything you created under `top1`, with the timestamps preserved. (Hint: The fastest way to do this is with a single recursive copy command, as you did in [Lab Worksheet #03 HTML][Worksheet #3 HTML], but add the option to preserve timestamps.) 8. Create an empty file named `MT` in each of the five directories from `top2` down. (You can do this with one command name and five pathnames.) 9. Make the `top2` directory your current directory and then use a command to recursively generate a list of all pathnames under your current directory. The recursive output of all pathnames under your current directory will be exactly ten lines long and will contain this **exact** line in the output somewhere (along with another nine lines): `./dir2/dir2-1/MT` Note that there is no punctuation at the end of any pathname. 10. When the recursive output above on your screen looks correct, redirect the ten lines of output of the command into the file named “`top2find.txt`” in the `assignment03` directory. The word count of this file must be: `10 10 103`. 11. Under `assignment03` create another directory `top3` that contains a copy of everything that you created under `top2`, with timestamps preserved. (Hint: See the previous Hint!) 12. Under `top3` rename each of the `MT` files to have the number of the parent directory that contains it, e.g. rename `./MT` to be `./MT3` and `dir2-1/MT` to be `dir2-1/MT2-1`, etc. 13. Make the `top3` directory your current directory and then use a command to recursively generate a list of all pathnames under your current directory. The recursive output of all pathnames under your current directory will be exactly ten lines long and will contain this **exact** line in the output somewhere (along with another nine lines): `./dir2/dir2-1/MT2-1` 14. When the recursive output above on your screen looks correct, redirect the ten lines of output of the command into the file named “`top3find.txt`” in the `assignment03` directory. The word count of this file must be: `10 10 112`. Run the [Checking Program] to verify your work so far. Finding multiple files in a maze -------------------------------- 15. Under the [Source Directory] there is a symbolic link named “`maze`” that leads to the same directory maze used in a previous assignment: [Assignment #2 HTML]. Again, you must find files in this maze, but the symbolic link requires some special handling because `find` does not follow symbolic links without using some options. You must choose one of these approaches: a. Use the maze pathname from the previous assignment, not the pathname in the [Source Directory] that is the symbolic link. (The `find` command will not follow symbolic links.) **OR** b. Use an option to the `find` program that makes it *follow symbolic links while processing the command line arguments*. (Hint: RTFM and do **not** use the `-L` option; you will get an error message.) **OR** c. Make the `maze` your current directory and then use `find`. (A current directory can never be a symbolic link - it must be a real directory.) 16. In this maze, use a single command to recursively find the three files 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 these 12-character file names. Do not try to use “`cd`” and “`ls`” to find the file in the maze; the maze is very big. 17. When you have found your three personal “`abcd0001-txt`” files in the maze, determine which file is not empty. Only one of the three files is not empty. (Hint: You can combine this step with the previous step if you remember how to search for files greater than zero size.) 18. Copy the non-empty file from the maze into your `assignment03` directory you created above. Read the file to make sure it is the right one (not empty) after you copy it. Run the [Checking Program] to verify your work so far. Searching for text inside files ------------------------------- As mentioned in [Lab Worksheet #03 HTML][Worksheet #3 HTML], choose which command you use depending on whether special characters are being used in the search string. 19. Search for lines containing your login userid in the password file and redirect the output into file `me.txt` under `assignment03`. You should find exactly one line. 20. Search for lines containing the *special character* dollar sign (“`$`”) in the file `bash.bashrc` in the [Source Directory] and redirect the output into file `dollar.txt` under `assignment03`. The word count of this file must be: `3 25 143`. 21. Run the command `last` to display the login times and, in the output of that command, search for lines that *do not* contain the string `pts`. Redirect the output into file `reboots.txt` under `assignment03`. The word count of this file will be about 7 or 8 lines, maybe a few more. Almost all the lines will start with `reboot`. That is all the tasks you need to do. Verify your word counts and then 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 `assignment03check` in the [Source Directory] on the CLS. You can execute this program by typing its (long) pathname into the shell: `$ ~idallen/cst8207/13w/assignment03/assignment03check` 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 `assignment03.txt` under your `assignment03` directory. Use the *exact* name `assignment03.txt` in your `assignment03` 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 `assignment03.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 `assignment03.txt` file under the correct Assignment area on Blackboard (with the exact name) before the due date. Upload the file via the **assignment03** “Upload Assignment” facility in Blackboard: click on the underlined **assignment03** 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 `assignment03` 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 [Worksheet #2 HTML]: worksheet02.html [Assignment #2 HTML]: assignment02.html [Worksheet #3 HTML]: worksheet03.html [Checking Program]: #checking-marking-and-submitting-your-work [Course Linux Server]: 010_course_linux_server.html [Lab Worksheet #03 ODT]: worksheet03.odt [Tasks]: #tasks [Source Directory]: #the-source-directory [File Transfer]: 015_file_transfer.html [Plain Text]: assignment03.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/