Due Tuesday 05/23 at 1:00 pm. No late submissions accepted.
Submission: Gradescope
Specification: Spec
This assignment focus on the Unix multi-user system and permissions. Advance warning: it can be tricky to “see” files that start with a dot in file dialog boxes when you are trying to, for example, upload them to Gradescope. Check out How to view “Hidden” (a.k.a. dot) files for more info.
wget https://courses.cs.washington.edu/courses/cse391/23sp/homework/hw8/hw8.tar.gz
# You can't unzip this yet, that is part of the first question
Task 1: : Bash shell commands¶
Warning
We recommend that you do this part on the CSE VM, and not on attu
/vergil
/cancun
etc. Some problems require super user permissions, which you don’t have on attu
/vergil
/cancun
etc. Moreover, these problems require you to change permissions on files and CSE Support dislikes a surge of 391 students coming to them to manually fix permissions they messed up for themselves on attu
.
However, if you are unable (or do not want) to install the VM, you can submit to Gradescope to check your solutions.
For each item below, determine a single bash shell statement that will perform the operation(s) requested. Each solution must be a one-line shell statement, but you may use operators such as >
, >>
, <
, |
, &&
, and ;
. For all commands, do not create any files except those indicated.
To test your commands, you should have downloaded and unpacked hw8.tar.gz
into the current directory using the command that will be the answer to question #1. You can assume you are in the hw8
directory when doing these problems.
In response to each question, you will provide the command that will perform the task described, not the output that the command produces. Write your commands in on the indicated lines in the task1.sh
file in the hw8
folder.
Problem 1¶
🔍 Self-Discovery
The tar
command compresses/decompresses files in the Unix TAR (“tape archive”) file format. TAR merges many files into a single archive; however, unlike ZIP, TAR does not compress the contents. Therefore most .tar
files are then subsequently also compressed with a separate compression algorithm called GNU ZIP (“gzip
”), which yields a .tar.gz
file. (This format was used over ZIP because of patent issues.)
For this exercise, show a single command that will decompress the file hw8.tar.gz
into the current directory in “verbose” mode, so that it echoes each file that is coming out of the archive.
Info
You don’t need |
, &&
, ;
, et.c to solve this problem.
Info
If you don’t know how to use a particular command, where should you go to learn more about it?
Problem 2¶
Set the file README.md
so that its owner and others can execute the file. (All other permissions should remain unchanged.)
Problem 3¶
Set all .java
files in the current directory and all its subdirectories (and sub-sub-directories, etc. recursively) to have read permission for all users.
Problem 4¶
a. Set all files with extensions .html
in the current directory and all its subdirectories to be readable, writeable and executable their owner and only readable (not writeable or executable) by groups and others. Do this using the standard letter code arguments for granting and removing permissions. Note: Some of the files have spaces in their name which will confuse the relevant commands you’ll need. Read the man
pages for options on handling file names with spaces.
b. Write this same command using the octal number code arguments to grant/remove the permissions
Problem 5¶
Set all files in the current directory and all its subdirectories (and sub-sub-directories, etc. recursively) to be owned by the group wheel
. (If you can’t get this to work see the tips here.)
Problem 6¶
🔍 Self-Discovery
The umask
command is used to specify what permissions are given by default to newly created files. Check the slides from lecture to see a more detailed discussion of how to use umask
. Its format might be the opposite of what you expect — it actually specifies what permissions will be taken away.
Use umask
to set the default permissions for new files to be read (but not write or execute) permission to you (the owner), but no permissions to anyone else.
Problem 7¶
🔍 Self-Discovery
Give a command that would print out the contents of the file password.secret
as the root super-user. Notice that you do not have the permissions simply print the contents of this file normally, as you will get a Permission denied error. Running the command to print the file as the root super-user will allow you to see the contents of the file without needing to change the file’s permissions.
Note
Depending on where you are trying to do this, the actual command may not work. Specifically, on attu
/vergil
/cancun
etc you do not have permissions to do this, but you should on your VM. Give the command that you would use, even if it doesn’t work in your environment.
If you are unable (or do not want) to install the VM, you can submit your solution to Gradescope to check your answer.
Task 2: .bashrc
¶
As we have discussed in class, .bashrc
is a script that runs every time you start a new Bash shell (e.g. by typing bash
at the bash prompt. .bashrc
is also run when opening a new terminal window on the CSE VM). For this part of this assignment, you should modify the .bashrc
file in your home directory on your Linux environment so that it sets the following aliases. If you have an account on attu
or another shared server, you probably already have a .bashrc
file there that you can modify. If your system does not have such a file, you can just create a file named .bashrc
and add your aliases there.
Submit your modified .bashrc
file with the following aliases.
- Add an alias so that typing
attu
connects you toattu.cs.washington.edu
via SSH. (This alias isn’t very useful if you’re testing onattu
itself, but set it up anyway.)- If the server you are using is
vergil
orcancun
etc, set up an alias so that typingattu
(notvergil
/cancun
etc!) connects you to there instead (e.g. tovergil.u.washington.edu
).
- If the server you are using is
-
(a) Add an alias so that when trying to overwrite a file during a move operation, the user is prompted for confirmation first. (Hint: Set the operation to run in “interactive mode”.)
(b) Add an alias to create the same behavior for the copy operation.
Task 3: .bash_profile
¶
As we have discussed, .bash_profile
is a script that runs every time you log in to a Bash shell. This will happen every time you log on to attu
. (On the VM things are bit more complex due to how they have configured things. A terminal window is also not considered a “login shell”. You can run your .bash_profile
by starting a shell by typing bash –l
(“el”) in a terminal window.)
In general if you want to make personalizations to your environment that produce output (e.g. print something to the screen) you should put them in your .bash_profile
rather than in your .bashrc
. If you have an account on attu
or another shared server, you probably already have a .bash_profile
file there that you can modify. If your system does not have such a file, you can just create a file named .bash_profile
and add your changes there.
For the item below, submit your modified .bash_profile file.
- Display a personalized message when logging on to the system. (e.g. “Welcome Ruth! Have a great day!”) You can do this by just listing the command you would execute at the bottom of your
.bash_profile
. Feel free to get creative with this! Anything will be fine here as long as it prints some output to the screen that would not have happened otherwise. (but please keep messages positive and respectful!)