Updated: 2018-09-22 22:19 EDT

1 Due Date and DeliverablesIndexup to index

Do not print this assignment on paper!

2 Purpose of this AssignmentIndexup to index

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 using the man command, and use the less pagination program.
  6. Learn how to submit course work to Brightspace using exact file names.

Remember to READ ALL THE WORDS to work effectively and not waste time.

3 Introduction and OverviewIndexup to index

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 each Task listed below, in order.
  2. Verify your own work in a task before running the Checking Program.
  3. When you finish a task, run the Checking Program to help you find errors. Fix the errors.
  4. When you have done all the tasks, submit the output of the Checking Program to Brightspace before the due date.
  5. You don’t have to finish all the tasks before you upload. Uploading a partially-completed assignment is fine. You can upload a more complete assignment later.
  6. 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.

3.1 The Source DirectoryIndexup to index

All references to the Source Directory below are to the CLS directory ~idallen/cst8207/18f/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.

4 TasksIndexup to index

4.1 Remote network log in to the Course Linux ServerIndexup to index

First, you must log in remotely to the Course Linux Server. Most system admin work is done via remote log-in like this; you are rarely sitting in front of the machine you are administering.

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. Read the notes and attend any lab period for further 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. A List of Commands is available each week.

  1. Do a Remote Login to the Course Linux Server from any existing computer, using the host name appropriate for whether you are on-campus or off-campus and using the terminal program appropriate to your operating system (e.g. use PuTTY on Windows, or Terminal with ssh on Mac OSX).
    • Get your special CLS password from Brightspace.

4.2 Security – Change your CLS passwordIndexup to index

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.

  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.

4.3 Simple Commands and Output RedirectionIndexup to index

This task shows you some simple Linux command lines that were introduced in class and lab. It also demonstrates file Output Redirection using the > character, where you can save the output of a Linux command line in a file instead of having the output display on your screen.

All of these Linux command names have manual pages – man pages – and you can read the manual page for a command by using the man command followed by the name of the command, e.g. man date or man users

  1. As you did in class, try each of the Linux command lines below at the bash shell prompt on the CLS. Do not type the leading dollar ($) prompt character. Only type the command name and any arguments to the command, separated by spaces as you see below.

    1. 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.
    2. If you stop seeing the shell dollar 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.
    3. You can remove (delete) any file you create by using the rm command, e.g. rm cal.txt would remove the cal.txt file.

    1. $ date
    2. $ users
    3. $ who
    4. $ echo Hello World
    5. $ cal 9 1752
    6. $ figlet Hello World
    7. $ toilet Hello World
    8. $ history

    • Note the odd number of days in September 1752, to correct the calendar for errors in leap years. For more on leap years, watch Neil deGrasse Tyson on Leap Years
    • 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.
    • Other fun commands are fortune, sl, and cmatrix -s
  2. Create a file named date.txt on the CLS as follows: Use shell file Output Redirection to 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 date and the added redirection syntax that uses the right angle bracket. You can add redirection syntax to most any Unix/Linux command line.

    Removing files: You can remove (delete) any file you create by using the rm command, e.g. rm date.txt would remove the date.txt file. (Did you write this command in your notebook of Linux commands?)

  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 (it’s a dash followed by a letter, not a digit) to get more information about files, like this:
    • $ ls
    • $ ls -l
    • $ ls -l date.txt

    Use the above three command lines and note how the output differs. (Did you write this command and option in your notebook of Linux commands?)

  4. The file command takes one or more pathname arguments and tells you what type of thing each name is. Use the command to show the type of the date.txt file you just created and see that it is an ASCII text file. You can try other pathnames, too. Here are examples of commands and their output; try all of them yourself:

    $ file date.txt
    date.txt: ASCII text
    
    $ file /dev/null
    /dev/null: character special (1/3)
    
    $ file /
    /: directory
    
    $ file .
    .: directory

    Try each of the above command lines and make sure you see the same output on your screen. (Did you write this command name in your notebook of Linux commands?)

  5. The command cat displays the contents of a file on your screen:
    • $ cat date.txt

    Use the above command line to display on your screen the contents of the date.txt file you created earlier using Output Redirection. (If you get an error No such file or directory, check your spelling.)

  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                           # use ls command to show file size, date information
    -rw-rw-r-- 1 abcd0001 abcd0001 12 Jan 15 05:12 foo
    
    $ file foo                            # use file command to show the type of the file
    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 of the simple Linux commands that you used at the start of this task, exactly as you used each above, with the same command arguments, redirecting the output of each of the 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 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 output files (corresponding to the 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.

4.4 File Transfer to/from the CLSIndexup to index

Your instructor will walk you through File Transfer in your lab period. Come to any lab period for assistance in making this work for you.

Do a practice File Transfer, fetching a file from the CLS to your local machine (e.g. to your local Windows or OSX laptop), like this:

  1. First, create a file linux.txt on the Linux CLS containing some calendar output. You can create this file using file output redirection, as you did above. Use ls to see the file name and cat to see the content of the linux.txt file, as you did above. Make sure the file is not empty!

  2. Transfer the above linux.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, or use a Terminal with the scp command for Mac OSX.
    • Your instructor will demonstrate using File Transfer in a lab period. Come to any lab period for assistance in making this work for you.
  3. After you transfer the linux.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 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.

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 to Brightspace for marking.

4.5 Linux manual pages: the man commandIndexup to index

You need to know RTFM in the Manual to do this task, especially the section on Reading manual pages SYNOPSIS Line(s).

There are no electronic deliverables for this task, but your instructor may ask you in the lab about the answers to the five questions in the above RTFM page relating to the SYNOPSIS section of a manual page.

Be ready with any of the five answers, and show that you know how to search for text inside manual pages (inside the less program).

4.6 When you are doneIndexup to index

That is all the tasks you need to do.

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 Brightspace following the directions below.

Your instructor will also mark the files 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

Nothing seriously bad will happen if you forget to log out, but you may leave behind an empty, “ghost” login session that may take some days to time out and disappear. Always exit before you close your laptop, PuTTY, or Terminal session.

5 Checking, Marking, and Submitting your WorkIndexup to index

Summary: Do some tasks in this Assignment, 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 are done the assignment or have the best mark you can get, save the output of the Checking Program into a file using output redirection and then upload that one output file to Brightspace for marking.

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/18f/assignment02/assignment02check

    Note the leading tilde ~ character on the command name. Do not type the dollar sign prompt. Use the Enter key at the end of the line. You will learn of ways to make this long line 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. The output will be long and will scroll off the top of your terminal window. You can probably use the PAGE UP key to see the scrolled text.

    You may run the Checking Program as many times as you wish, allowing you to correct mistakes and get the best assignment 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 in your Base Directory on the CLS, like this:

    $ ~idallen/cst8207/18f/assignment02/assignment02check >assignment02.txt
    • Use standard output redirection with that exact assignment02.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.

    You can view the output file one-page-at-a-time using the less program (use the space bar to page forward and use the letter q to quit):

    $ less assignment02.txt
    • In less use the space bar to page forward and use the letter q to quit).
    • 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.
    • 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 single assignment02.txt file from your local computer to the correct A-02 Assignment #02 area on Brightspace before the due date.
    • See Assignment #01 for details on how to upload files to Brightspace.
    • Only upload the one file that is the standard output of the Checking Program.
    • Make sure the file has the correct assignment02.txt name.
    • Make sure you upload it to the right place, not into Assignment 1!
  6. 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!

Notes:

READ ALL THE WORDS. OH PLEASE, PLEASE, PLEASE READ ALL THE WORDS!

Author: 
| 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

Campaign for non-browser-specific HTML   Valid XHTML 1.0 Transitional   Valid CSS!   Creative Commons by nc sa 3.0   Hacker Ideals Emblem   Author Ian! D. Allen