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 GitHub repository and push your work by noon
Saturday, January 27.
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 Pull Request workflow describe in Reading 01.
To create a homework01
branch in your local repository, follow the
instructions below:
$ cd path/to/cse-20289-sp24-assignments # Go to assignments repository
$ git switch master # Make sure we are in master branch
$ git pull --rebase # Make sure we are up-to-date with GitHub
$ 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.
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.sp24/static/txt/homework01/GUIDE
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
$ curl -LO https://www3.nd.edu/~pbui/teaching/cse.20289.sp24/static/txt/homework01/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
Checking homework01 tasks ...
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 / 10.00
Status Success
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!
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 |
If you need additional reference information, please refer to the readings from Reading 01:
Chapter 10 - Processes
You may also wish to read the following chapters:
Chapter 18 - Archiving And Backup
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.
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.
To check your quiz directly, you can use the check.py
script:
$ ../.scripts/check.py
Checking homework01 quiz ...
Q01 0.20
Q02 0.20
Q03 0.20
Q04 0.20
Q05 0.20
Score 1.00 / 1.00
Status Success
For extra credit, read the following chapters from The Linux Command Line:
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:
To get credit for this Guru Point, show your bash shell customizations to a TA to verify (or attach a screenshot or video to your Pull Request). You have up until one week after this assignment is due to verify your Guru Point.
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 Pull Request of your intentions.
To submit your assignment, please commit your work to the homework01
folder
of your homework01
branch in your assignments GitHub repository:
#-----------------------------------------------------------------------
# Make sure you have already completed Activity 0: Branching
#-----------------------------------------------------------------------
...
$ 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 "Homework 01: Activity 1 completed" # Record changes
...
$ git add answers.json # Mark changes for commit
$ git commit -m "Homework 01: Activity 2 completed" # Record changes
...
$ git push -u origin homework01 # Push branch to GitHub
Remember to create a Pull Request and assign the appropriate TA from the Reading 01 TA List.
DO NOT MERGE your own Pull Request. The TAs use open Pull Requests to keep track of which assignments to grade. Closing them yourself will cause a delay in grading and confuse the TAs.