Updated: 2015-09-09 17:12 EDT

1 Due Date and Deliverables

Do not print this assignment on paper!

2 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.

  1. Review Remote Login to the Course Linux Server (CLS)
  2. Review basic Linux command line operations and utilities, e.g. from CST8207 GNU/Linux Operating Systems I.

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

3 Introduction and Overview

This is an overview of how you are expected to complete this assignment. Read all the words before you start working.

You will create file system structure in your CLS HOME directory, including various directories, files, and links.

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 mark, and you can submit your mark as many times as you like before the due date.

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 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; you must have your term work available right until term end.

This is a review lab, and all of the tasks can be completed with knowledge of the material from the prerequisite course CST8207 GNU/Linux Operating Systems I; however, you will probably need to refresh your memory of various topics by referring to the CST8207 course notes and the Linux man pages. Your lab instructor is there to help you, but s/he will want you to have tried consulting the notes and man pages first.

3.1 The Source Directory

All references to the Source Directory below are to the CLS directory ~idallen/cst8177/15w/assignment01/ 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.

3.2 Searching the course notes on the CLS

The previous term’s course notes are available on the Internet here: CST8207 GNU/Linux Operating Systems I. All the notes files are also searchable on the CLS. You can recall how to read and search these files using the command line on the CLS under the heading Copies of the CST8207 course notes near the bottom of the page Course Linux Server Course Notes.

4 Tasks

For full marks, follow these task directions below exactly as written. READ ALL THE WORDS to work effectively and not waste your time.

  1. Complete the Tasks listed below, in order, from top to bottom.
  2. Do not skip steps.
  3. These tasks must be done in your account on the Course Linux Server.
  4. Verify your own work before running the Checking Program.
  5. Run the Checking Program to help you find errors and grade your work.
  6. Submit the grading output of the Checking Program to Blackboard before the due date.

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.

4.1 Set Up – The Base Directory on the CLS

  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. All work in this assignment must be done on the CLS.

Your account password is the same one you used last term. If you have never used the CLS before, or you forget your password, see your instructor for the special non-Algonquin password you must use.

If you make too many password failure attempts you will lock your current IP address out of the CLS. Your instructors can un-block your IP address. Changing IP addresses will circumvent the lock-out.

  1. If you haven’t taken the prerequisite course CST8207 GNU/Linux Operating Systems I using the CLS, you will need to read Startup Files to know what lines to place in your .bash_profile and .bashrc before beginning this assignment.

  2. Make the CLS directory ~/CST8177-15W/Assignments/assignment01, in which you will create the files and links resulting from the following tasks.

This CLS assignment01 directory is the Base Directory for most pathnames in this assignment. Store your files and answers in this Base Directory on the CLS.

  1. Create the check symbolic link needed to run the Checking Program, as described in the section Checking Program below.

Use the symbolic link to run the Checking Program to verify your work so far.

4.2 Simple Tasks

  1. From your HOME directory, not the Base Directory, use the ls command with options to give a long listing (showing permissions), include all hidden files, include inode numbers, and recursively include all subdirectories. (Do not use any other options.) When the output is correct, redirect the output of this command into new file listing_start.txt in the Base Directory – it will be at least 16 lines of output. (If you have files from other terms in your account, you may get some “permission denied” errors doing the listing [ignore the errors] and the number will be many more than 16 lines.)

  2. Run the whoami command. When the output is correct, redirect the output of this command into new file whoami.txt under the Base Directory.

  3. Run the command that shows output in the following format, but for your own userid:

    uid=1000(abcd0001) gid=1000(abcd0001) groups=1000(abcd0001),4(adm),999(student)

    Append the output of this command to existing file whoami.txt under the Base Directory. Note the word append; the file must now have two lines of output in it. Both lines must contain your userid.

  4. Use a command to count only the number of lines (not characters or words) in file read.txt in the Source Directory, using the absolute pathname of the file. (You’ll know you have the right file if the size is 838 characters.) When the output is correct (one line), redirect the output of this command (the output containing only the line count number and the absolute pathname, not any other numbers) into new file lines.txt under the Base Directory.

  5. Use a command to search for and display the single line containing the exact three-word text phrase “permissions is useless” located inside any one of the text files (files having a .txt file extension) located in the notes/ directory of the previous term CST8207 (14F: Fall 2014) on the CLS. The Introduction and Overview explains where to find these notes and how to search the notes, just as you did last term. When the output is correct, redirect the one line of output of this command into new file L I l 1.txt under the Base Directory. The file should be one line long. Pay attention to each of the different characters in the 11-character file name, especially the three spaces.

  6. Rename the file lines.txt to have the new name 0 O o.txt in the same directory. Pay attention to each of the different characters in the 9-character file name, especially the two spaces.

Check your work so far using the check program symlink.

4.3 File Permission Tasks

  1. Copy the binary program file /bin/hostname three times to files named read only, write only, and execute only under your Base Directory, preserving the file modify times. This is a BINARY program file, so do not display the content of the file on your terminal screen! Pay careful attention to the single space characters in each file name.

  2. Change the permissions on all three copied files so that group and other have no permissions. (You can do this with one command name and a file GLOB pattern.)

  3. Change the permissions on the read only file so that only you can read the file but not write or execute the file.
    1. Verify readability of the file by using any command that reads the content of the file. For example, you can word count the file or try to copy the file to /dev/null.
    2. Verify non-writability by attempting to overwrite the file. Attempts to overwrite should fail with “permission denied”.
    3. Verify non-executability by attempting to execute the file as a program. It should fail with “permission denied”. (You may need to review how to execute a file using a pathname. The error must be “permission denied” not “no such file” or “command not found”.)
  4. Change the permissions on the write only file so that only you can write (including append to) the file but not read or execute the file.
    1. Using operations similar to the previous file, verify that you can write the file but not read or execute it.
  5. Change the permissions on the execute only file so that only you can execute the file but not read or write the file.
    1. Using operations similar to the previous files, verify that you can execute the file but not read or write it.

Check your work so far using the check program symlink.

4.4 Directory Permission Tasks

  1. Make the following directory structure under the Base Directory:

    permissions/
    permissions/read|only/
    permissions/write|only/
    permissions/execute|only/
    permissions/ /

    Pay special attention to the unusual characters in the names.

  2. Change the permissions on the permissions/ directory so the owner (you) can read, write, and search, but group and other have no permissions.

  3. Change the permissions on all four subdirectories of permissions/ so that that group and other have no permissions. (You can do this with one command name and a GLOB pattern.)

  4. Change the permissions on read|only/ so that you can see the names in the directory, but cannot take an accurate long listing, and cannot create files, and cannot cd into the directory. (Verify that you can/cannot do these things!)

    Hint: Of course seeing names in the directory will only show names if you actually create those names.

  5. Change the permissions on write|only/ so that you cannot see the names in the directory, but you can add new files to the directory, delete files from the directory, and cd into the directory. (Verify that you can/cannot do these things!)

  6. Change the permissions on execute|only/ so that you can (only) cd into the directory. You cannot see the names in the directory or add or delete files from the directory. Verify!

  7. Change the permissions on the single-blank name so that you can not read the directory, write the directory, or cd into the directory.

Check your work so far using the check program symlink.

4.5 Finding files in a maze

  1. Under the Source Directory there is a directory named maze (four letters). Put the absolute pathname of this directory into a file in your Base Directory with a basename similar to .abcd0001.txt, but use the basename that starts with a period followed by your own Blackboard userid, not the fake userid abcd0001. Use your own userid in the file name.

  2. This maze contains many hidden sub-directories. Use a single command (no pipes needed) to find in the maze a single hidden file with a basename similar to .abcd0001*txt, but look for the basename that starts with a period followed by your own Blackboard userid, not the fake userid abcd0001. To look for the file, replace the string abcd0001 in .abcd0001*txt with your own userid before you look. The basename you find must be exactly 13 characters long and contain a period and a real asterisk. It must have no leading or trailing blanks around it.

    Hint#1: You must use a single command (not a pipeline) that is good at Finding Files by basename to do this. Do not try to use cd and ls to find your file; the maze is really, really big.

    Hint#2: If you want to find a name containing a real asterisk character, you need to escape the asterisk to stop it from being used as a pattern character (wildcard), and you need to do this both for the shell that reads your command line and for the command that finds the files. Review how the shell handles special characters in Quoting. if you get the escaping right, you will find exactly one file name.

    Hint#3: If you get an error or Usage message such as paths must precede expression, you didn’t get Hint#2 correct. Review how the shell handles special characters in Quoting.

  3. When you find the right file basename (there is only one for your userid), put its shortest full absolute pathname into new file foundmaze.txt in your Base Directory. Note: Shortest absolute pathnames contain no /./ or /../ or tilde (“~”) expressions; simplify the path to the shortest possible absolute pathname.

Check your work so far using the check program symlink.

4.8 Data Mining Tasks

You may find Data Mining and Examples of Pipes useful to complete these tasks. You need to remember where System Log Files are stored.

  1. Count the number of lines containing the exact two-word text phrase “refused connect” in the CLS system log file named auth.log.1 under the standard system logs directory. Put the number of lines (one number) into a file auth.txt in your Base Directory. Hint: The command that searches for text strings inside files has an option to count them for you.

  2. Count the number of lines containing the exact two-word text phrase “Failed password” in the CLS system log file named auth.log.1 under the standard system logs directory. Append the number of lines (one number) to the file auth.txt in your Base Directory, so that the file now has two lines in it, one number on each line.

  3. For the text string that occurs less often in auth.txt, create a multi-command data-mining pipeline to display a list of the dozen most frequent IP addresses used on those lines, preceded by the occurrence count, in descending order, and save the dozen lines of pipeline output in file data.txt in your Base Directory.

    Hint: The first few lines of output should be identical to this, indicating that IP address string (222.161.4.149) occurred 336 times on those lines:

    336 (222.161.4.149)
    309 (221.235.189.245)
    302 (221.235.189.244)
    ...etc...

    Hint: To confirm the above answer, you can search for the text (222.161.4.149) in auth.log.1 and count on how many lines it occurs. The answer should be 336 lines.

    Hints: If you see a host name instead of an IP address anywhere in the dozen lines, you’re looking at the wrong field in the line; use the next field instead. My sample solution came almost directly from the examples in above course notes and used six commands (one command name was used twice) separated by five pipes.

  4. Use a text editor to place a copy of the command pipeline you used onto a single line in file data.sh in your Base Directory. Underneath the pipeline, in the same file, on separate lines, write numbered comments explaining in your own words what each command in the pipeline does. It must look similar to this (though this is the wrong pipeline to use for this task):

    ee 'http://www.die.net/moon/' | fgrep -A2 'Moon Phase' | head -n 3 | tail -n 1
    1. ee: alias for "elinks -dump -no-numbering -no-references"
    2. fgrep -A2: extract lines containing "Moon Phase" and two following lines
    3. head -n3: keep only the first three lines
    4. tail -n1: keep only the last line of the above three (the moon phase)

    If there are six commands in your data-mining pipeline, you will need to write six numbered comment lines to explain each of them and your data.sh file will be seven lines long.

Check your work so far using the check program symlink.

4.9 Finishing Tasks

  1. Make a backup copy of your listing_start.txt file, in case you accidentally overwrite it in the next step.

  2. From the same starting directory, repeat the command you used to create listing_start.txt at the beginning of this lab, but redirect the output this time into the file listing_end.txt in the same directory as listing_start.txt, and make sure that all errors (standard error output) also go into the output file and not on the screen.

    Hints: The first five words in the previous paragraph are very important. You might find your shell history useful here. There is a special syntax to also redirect error messages into a file using Shell I/O Redirection.

  3. Use the diff command to compare the earlier listing file to the previous one you did before starting this lab. Note the many changes!

Check your work so far using the check program symlink.

4.10 When you are done

That is all the tasks you need to do.

Read your CLS Linux EMail and remove any messages that may be waiting. See Reading eMail for help.

Check your work a final time using the Checking Program and save the standard output as described below. Submit your mark following the directions below.

5 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.

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 assignment01check in the Source Directory on the CLS. Create a Symbolic Link to this program named check under your new Base Directory on the CLS so that you can easily run the program to check your work and assign your work a mark on the CLS. Note: You can create a symbolic link to this executable program but you do not have permission to read or copy the program file.

  2. Execute the above check program on the CLS using its symbolic link. (Review the Search Path notes if you forget how to run a program by pathname from the command line.) 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 task 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 only the standard output of the Checking Program into the text file assignment01.txt under your Base Directory on the CLS. 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. Submit it exactly as given.
    • 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 assignment01.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.
    • Do not edit the output file. Submit it exactly as given.
    • 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!
  5. Upload the assignment01.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 assignment01 link for this assignment.
      1. If this is your first upload, the Upload Assignment page will open directly; skip the next sentence.
      2. 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.
    1. Verify that your latest Attempt has the correct 16-character, lower-case file name under the SUBMISSION heading.
    2. The one file name must be the only thing under the SUBMISSION heading. Only the one file name is allowed.
    3. No COMMENTS heading should be visible on the page. Do not enter any comments when you upload an assignment.
    4. 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 assignment01 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!

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

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

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