% CST8207 Assignment 02 – Course Linux Server simple commands % Ian! D. Allen – – [www.idallen.com] % Winter 2015 - January to Apil 2015 - Updated Fri Jan 16 19:29:17 EST 2015 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**: `15h00 (3pm) Tuesday January 20, 2015 (start of Week 3)` - Your next assignment will be available in a few days and will overlap this assignment. Start work on this now! Don’t delay! - Late assignments or wrong file names may not be marked. Please be accurate and punctual. - **Available online** - Version 1 – 14:00 January 13, 2015 - Version 2 – 06:00 January 15, 2015 – clarified wording and added more web links to notes - **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 plain text file uploaded to Blackboard according to the steps in the [Checking Program] section below. 2. Using [Remote Login] to connect to the [Course Linux Server] (**CLS**), use simple commands in [The Unix/Linux Shell] to create some files in your account on the CLS. **Do not delete any assignment work from the CLS until after the term is over!** 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. Learn how to log in using [Remote Login] to the [Course Linux Server] and use simple commands in [The Unix/Linux Shell]. 2. Upgrade your [Course Linux Server] (**CLS**) password security. 3. Learn how to redirect the output of a command into a file. 4. 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. 5. Learn to [RTFM in the Manual] and use the `less` pagination program. 6. Learn how to submit course work to Blackboard using exact file names. 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. For full marks, follow these directions exactly. 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 the files and directories in place on the CLS as part of your deliverables. **Do not delete any assignment work 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/15w/assignment02/` 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 ===== - 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. - Run the **Checking Program** to grade your work, then upload the file containing the output of the **Checking Program** to Blackboard. - 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. - **Do not delete any assignment work from the CLS until after the course is over.** Remote network log in to the Course Linux Server ------------------------------------------------ See [Remote Login] for the background you need to read the document [Course Linux Server]. Your instructor will demonstrate logging in to the [Course Linux Server] and the commands below and [File Transfer] in your lab periods in the first two weeks of school. Attend any lab period for assistance. Keep notes for every command name used in this course, giving its name, an explanation of what it does, and a short example. Quizzes and tests will require you to remember these command names. 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 and the terminal program appropriate to your operating system (e.g. use `PuTTY` on Windows and `Terminal` with `ssh` on Mac OSX). - Get your special CLS password from your instructor. - Most system admin work is done via remote log-in like this. - **All work in this assignment must be done on the CLS.** Security – Change your CLS password ----------------------------------- The CLS is on the public Internet; security is important. Choose your password carefully, or else Internet attackers will break into the CLS through your account. Don’t let this happen! 1. Read on Wikipedia: [Guidelines for strong passwords] 2. Read this [XKCD comic on good passwords] 3. Now [RTFM in the Manual] for the Linux 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. > Accounts that do not have their passwords changed before the due date of > this assignment will be **disabled**. Simple Commands and Output Redirection -------------------------------------- This task shows you some simple Linux command lines that were already introduced in last week’s lab. It introduces the idea of **output redirection** where you can save the output of a Linux command line in a file. 1. As you did last week, try the eight Linux command lines below at the `bash` shell prompt on the CLS. a. The syntax and format of Unix/Linux command lines is described in [Typing Command Lines] and [Basic Command Line Syntax]. Read those pages to know how to distinguish a **command name** from command **arguments**. b. If you stop seeing the prompt string after you enter a command and push `Enter`, try typing `^C` (`CTRL-C` – hold down the `Ctrl` key and type the letter `C` at the same time) to interrupt the command and get the `bash` dollar prompt back. This is described in [Interrupting Programs with `^C`]. 1. `$ date` 2. `$ users` 3. `$ who` 4. `$ echo Hello World` 5. `$ figlet Hello World` 6. `$ toilet Hello World` 7. `$ cal 9 1752` - Note the odd number of days in this month. - Try using `cal` with the year or month and year you were born, e.g. `cal 1954` or `cal 7 1954` - You can find out on what day of the week were you born. 8. `$ history` 2. Create a file named `date.txt` on the CLS as follows: Redirect (save) the output of the `date` command into an output file by adding to the right end of the command line a space, the right angle-bracket redirection character `>`, and then an output file named `date.txt` on the command line, like this: - `$ date >date.txt` Note the space between the command name and the added redirection syntax. You can add redirection syntax to most any Unix/Linux command line. 3. The command `ls` shows the names of files in your account, and it should show you the name of the `date.txt` file you just created. You can use the `-l` option to get more information, like this: - `$ ls` - `$ ls -l` - `$ ls -l date.txt` 4. The `file` command tells you what type of file it is (text): - `$ file date.txt` 5. The command `cat` displays the contents of a file on your screen: - `$ cat date.txt` 6. We can repeat the same sequence of commands with most any Unix/Linux command. We could redirect the output of the `echo` command into a file named `foo`, show the properties of the file, and then show the contents of the file: $ echo Hello World Hello World (output appears on your screen) $ echo Hello World >foo (output goes into the file foo) $ ls -l foo -rw-rw-r-- 1 abcd0001 abcd0001 12 Jan 15 05:12 foo $ file foo foo: ASCII text $ cat foo (display file contents on screen) Hello World 7. Using the left angle-bracket `>` followed by a file name allows you to **redirect** or save the output of almost any Linux command into any file name. This is called **Output Redirection**. We will cover redirection in more detail later in the course. Re-do all eight of the simple Linux commands that you used at the start of this task, exactly as you used each above, redirecting the output of each of the eight commands into a file that is the **name** of the command with a `.txt` extension added. Use the same command arguments as given above. View the file contents after each command. It will look like this: $ date >date.txt $ cat date.txt $ echo Hello World >echo.txt $ cat echo.txt Repeat for all eight of the commands used at the start of this task. The output file name uses the **name** of the command (not including any arguments to the command). Leave these eight output files (corresponding to the eight command names) in your account on the CLS. The syntax and format of each command line is described in [Typing Command Lines] and [Basic Command Line Syntax]. Read those pages to know how to distinguish a **command name** from command **arguments**. Your output file names must use only the **command name** not the command **arguments**. Run the [Checking Program] to verify your work so far. File Transfer to/from the CLS ----------------------------- > Your instructor will walk you through the following File Transfer task in > your lab period in Week 2. There is nothing to hand in from this task. Do a practice File Transfer, fetching from the CLS to your local machine (e.g. to your local Windows or OSX laptop), like this: 1. First, make sure you have a file `cal.txt` on the Linux CLS containing some calendar output. You can create this file using output redirection, as you did above. Use `ls` to see the file name and `cat` to see the content of the `cal.txt` file, as you did above. Make sure the file is not empty! 2. Transfer the above `cal.txt` file from the Linux CLS to your local machine using the instructions in the page [File Transfer]. - Choose the file transfer method applicable to your local operating system, e.g. use the `WinSCP` or `Filezilla` program for Windows and use a `Terminal` with the `scp` command for Mac OSX. - Your instructor will demonstrate this File Transfer in your lab period. Come to any lab period for assistance in making this work. 3. After you transfer the `cal.txt` file from the CLS to your local machine, open the transferred file on your local machine. - Under Windows try using both **Notepad** and then **Wordpad**. - Note the Windows problems with Linux text file line-endings when viewed with Windows Notepad; the whole calendar file appears to be one long line. - Linux and Windows text files are not compatible! - In the [File Transfer] notes, read about [Text File Line End Differences] - Macintosh users won’t have line-ending problems viewing Linux files. There is nothing to hand in from this practice task. You must know how to redirect program output into a file and transfer that file from the CLS to your local machine to be able to submit the output of the [Checking Program] for marking. When you are done ----------------- That is all the tasks you need to do. Check your work 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. 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**. 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 as a command name: $ ~idallen/cst8207/15w/assignment02/assignment02check You will learn of ways to make this shorter in future assignments. 2. Execute the above **Checking Program** as a command line on the CLS. This program will check your work, assign you a mark, and display the output on your screen. You may run the **Checking Program** as many times as you wish, allowing you to correct mistakes and get the best mark. 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 `assignment02.txt` on the CLS, like this: $ ~idallen/cst8207/15w/assignment02/assignment02check >assignment02.txt $ cat assignment02.txt - Use output redirection with that *exact* `assignment02.txt` file name. - Be absolutely accurate, as if your marks depended on it. - Case (upper/lower case letters) matters. - 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 `assignment02.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 this file! No empty files, please! 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 HAS YOUR MARKS IN IT!** 5. Upload the `assignment02.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 find the current assignment. 3. Under *Assignments*, click on the underlined **assignment02** 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 assignment file from your local computer. Make sure the assignment file has the correct name on your local computer before you attach it. 5. After you have attached the file on the *Upload Assignment* page, scroll down to the bottom of the page and use the *Submit* button to actually upload your attached assignment file to Blackboard. Use only *Attach File* on the *Upload Assignment* page. Do not enter any text into the *Text 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 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. 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) **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.) 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 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*. 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 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#Important_Notes__alphabetical_order_ [Assignments]: indexcgi.cgi#Assignments [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 [File Transfer]: 015_file_transfer.html [RTFM in the Manual]: 140_man_page_RTFM.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/ [Typing Command Lines]: 120_shell_basics.html#typing-command-lines [Basic Command Line Syntax]: 120_shell_basics.html#basic-command-line-syntax [Interrupting Programs with `^C`]: 120_shell_basics.html#interrupting-programs-with-c [Text File Line End Differences]: 015_file_transfer.html#text-file-line-end-differences [Source Directory]: #the-source-directory [EMail]: mailto:idallen@idallen.ca [Plain Text]: assignment02.txt [Pandoc Markdown]: http://johnmacfarlane.net/pandoc/