This Is Not The Course Website You Are Looking For

This course website is from a previous semester. If you are currently in the class, please make sure you are viewing the latest course website instead of this old one.

The goal of this homework assignment is to allow you to practice manipulating files, redirecting I/O, constructing pipelines, and signaling processes in a Unix environment.

For this assignment, you are to do your work in the homework01 folder of your assignments GitLab repository and push your work by 11:59 AM Saturday, January 25.

Activity 0: Branching

As discussed in class, each reading and homework assignment must be completed in its own git branch; this will allow you to separate the work of each assignment and for you to use the merge request workflow describe in Reading 01.

To create a homework01 branch in your local repository, follow the instructions below:

$ cd path/to/cse-20289-sp20-assignments   # Go to assignments repository

$ git checkout master                     # Make sure we are in master branch

$ git pull --rebase                       # Make sure we are up-to-date with GitLab

$ git checkout -b homework01              # Create homework01 branch and check it out

$ cd homework01                           # Go into homework01 folder

Once these commands have been successfully performed, you are now ready to add, commit, and push any work required for this assignment.

Activity 1: Adventure Guide (9 Points)

The main activity for this assignment is to follow the prompts of your Adventure Guide, which takes the form of a program located at:

https://www3.nd.edu/~pbui/teaching/cse.20289.sp20/static/txt/GUIDE

Student Machines

For this assignment, you will need to use the CSE student machines or any other machine with access to the ESC NFS filesystem. This is because there are some resources that are only accessible via the ESC NFS.

You can use either curl or wget to download this program to your homework01 folder in your assignments repository and execute it as follows:

# Go to homework01 directory in assignments repository
$ cd path/to/assignments/homework01

# Download Adventure GUIDE
$ wget https://www3.nd.edu/~pbui/teaching/cse.20289.sp20/static/txt/GUIDE

# Run Adventure GUIDE
$ python3 GUIDE
...

As you can see in the demonstration video below, the GUIDE script will prompt you to complete a series of tasks (19 in total). After you complete each task, you must run the GUIDE script so it can verify your work. If it detects that you have completed the task, it will update the tasks.yaml file with a specially encoded checkpoint payload associated with your netid and the corresponding task. It will then prompt you with the next task.

You are to follow the prompts specified by the GUIDE until you have completed each of the tasks in the adventure. Because some tasks depend on others, there is no skipping ahead or going backwards. That said, you can always remove the checkpoints in the tasks.yaml file to go back to a particular task.

At the end of this activity, you should see the following output from the GUIDE:

$ ./GUIDE
Task 00. Checkout on homework01 branch                                ... Completed
Task 01. Make GUIDE executable                                        ... Completed
Task 02. Copy file                                                    ... Completed
Task 03. Extract archive                                              ... Completed
Task 04. Rename directory                                             ... Completed
Task 05. Remove archive                                               ... Completed
Task 06. Create empty file                                            ... Completed
Task 07. Redirection                                                  ... Completed
Task 08. Append to file                                               ... Completed
Task 09. Edit file                                                    ... Completed
Task 10. File size                                                    ... Completed
Task 11. Disk usage                                                   ... Completed
Task 12. Search file contents                                         ... Completed
Task 13. Search File names                                            ... Completed
Task 14. Sorting                                                      ... Completed
Task 15. Symlink                                                      ... Completed
Task 16. PID                                                          ... Completed
Task 17. Kill                                                         ... Completed
Task 18. Quiz                                                         ... Completed

   Score 10.00

Task Checkpoints

Note, that each task checkpoint in the tasks.yaml is specially encoded for your netid. This means that copying the checkpoint from another student or from a previous task will not work and will lead to a corruption warning that will anger the GUIDE. The only way to proceed through the activity is to actually do the tasks!

Adventure Companions

The following information will help you on your journey:

Command Description Example
cat Display the contents of a text file. cat README.md
chmod Change the permissions of a file. chmod 644 data.txt
cp Copy files or directories. cp source destination
du Display disk usage of files or directories. du /etc
find Recursively search file paths. find /etc -name '*ssl*'
grep Search contents of files. grep precious gollum.txt
kill Send signal to process by ID. kill -HUP 1
ln Create links to other files or directories. ln -s target symlink
ls List contents of directory or specified files. ls -l /etc
mv Move or rename a file or directory. mv old new
ps List processes on current system. ps ux
rm Remove file or directory. rm junk
sort Order data. sort data
stat View the meta-data associated with file or directory. stat data
tar Manage archived data. tar xvf archive

Operation Example
Redirect standard output command > output
Redirect standard output and standard error command > output 2>&1 || command &> output
Redirect standard output; overwrite file if it exists command >| output
Append standard output command >> output
Redirect standard output to another command command1 | command2
Redirect standard input command < input

References

If you need additional reference information, please refer to the readings from Reading 00:

  1. The Linux Command Line:

    • Chapter 6 - Redirection
    • Chapter 7 - Seeing the World as the Shell Sees it
    • Chapter 8 - Advanced Keyboard Tricks
    • Chapter 9 - Permissions
    • Chapter 10 - Processes

    You may also wish to read the following chapters:

    • Chapter 17 - Searching For Files
    • Chapter 18 - Archiving And Backup

Activity 2: Adventure Quiz (1 Point)

Once you have completed all the tasks specified by the GUIDE in Activity 1, you are to complete the following reflection quiz:

As with Reading 01, you will need to store your answers in a homework01/answers.json file. You can use the form above to generate the contents of this file, or you can write the JSON by hand.

Kill The TROLLs

The TROLL program is located at /escnfs/home/pbui/pub/bin/TROLL. Before you log off the student machine you are working on, you should make sure you have killed all of your TROLL processes.

Guru Point (1 Extra Credit Point)

For extra credit, read the following chapters from The Linux Command Line:

  1. Chapter 11 - The Environment
  2. Chapter 13 - Customizing the Prompt

Once you have read these chapters, you are to customize your bash shell prompt by adding useful information and colors and setting $EDITOR to your preferred text editor.

Here are some additional resources to help you customize your bash shell:

  1. How to Customize your Bash Prompt on a Linux VPS

  2. How to Customize (and Colorize) Your Bash Prompt

  3. Bash/Prompt customization

  4. EZPrompt: Easy Bash PS1 Generator

  5. In Unix, how do I set my default (preferred) editor?

Verification

To get credit for this Guru Point, show your bash shell customizations to the instructor or a TA to verify. You have up until one week after this assignment is due to verify your Guru Point.

Self-Service Extension

Remember that you can always forgo this Guru Point for two extra days to do the homework. That is, if you need an extension, you can simply skip the Guru Point and you will automatically have until Monday to complete the assignment for full credit.

Just leave a note on your Merge Request of your intensions.

Submission

To submit your assignment, please commit your work to the homework01 folder of your homework01 branch in your assignments GitLab repository:

$ cd path/to/cse-20289-sp20-assignments               # Go to assignments repository
$ git checkout master                                 # Make sure we are in master branch
$ git pull --rebase                                   # Make sure we are up-to-date with GitLab
$ git checkout -b homework01                          # Create homework01 branch and check it out
$ cd homework01                                       # Go to homework01 directory
...
$ git add Makefile                                    # Mark changes for commit
$ git add GUIDE                                       # Mark changes for commit
$ git add tasks.yaml                                  # Mark changes for commit
$ git commit -m "homework01: Activity 1 completed"    # Record changes
...
$ git add answers.json                                # Mark changes for commit
$ git commit -m "homework01: Activity 2 completed"    # Record changes
...
$ git push -u origin homework01                       # Push branch to GitLab

Merge Request

Remember to create a merge request and assign the appropriate TA from the Reading 01 TA List.

DO NOT MERGE your own merge request. The TAs use open merge requests to keep track of which assignments to grade. Closing them yourself will cause a delay in grading and confuse the TAs.