Exam (ECE/SS2022/G1): Do A Lot With Files And Directories¶
Precondition: Logged-In To Remote/Exam Computer¶
Public key deployed to remote computer (see SSH: Public Key Authentication)
Logged in to remote computer
$ ssh -p 2020 firstname.lastname@jfasch.bounceme.net
Danger
The exam must be done on the remote computer
Take care to not accidentally execute the following steps on your local machine!
Create Exam Skeleton (5 Points)¶
In your home directory, create a subdirectory
exam-01
.In the
~/exam-01
directory, create an empty (“skeleton”) tree as follows,
$ tree ~/exam-01/
~/exam-01/
├── credentials
├── private-place
└── public-place
Create Credentials Files (10 Points)¶
In the directory ~/exam-01/credentials
, create a bunch of files as follows:
Filename |
Content |
---|---|
|
Your UNIX username and user ID (UID), one line each; for example $ cat ~/exam-01/credentials/name
joerg.faschingbauer
1020
|
|
The name and group ID (GID) of your primary group, one line each; for example $ cat ~/exam-01/credentials/primary-group
joerg.faschingbauer
1020
|
|
The name and ID of your supplementary groups, one line each; for example $ cat ~/exam-01/credentials/supplementary-groups
joerg.faschingbauer 1020
ece20 1021
|
Hint
See Login? What Is That? for how to find out who you are.
Hint
You use the >>
operator to append a line to an existing file
(or to create that file if it doesn’t exist):
$ echo 8020 Graz >> somefile.txt
Public Place (10 Points)¶
Tune the permissions of the ~/exam-01/public-place
directory in a
way that
You can
look and
cd
into itcreate files in it
remove files from it
Your fellow members of the
ece20
groupcan look and
cd
into it (and thus see its contents)can not create files in it
can not remove files from it
Nobody else has any permissions in that directory
Hint
You use the -d
option (together with -l
of course) to the
ls
command to view the permissions of the directory itself,
not its contents.
For example, this shows the initial - not-yet-tuned - permissions of the directory:
$ pwd
/home/joerg.faschingbauer/exam-01
$ ls -ld public-place/
drwxr-xr-x 2 joerg.faschingbauer joerg.faschingbauer 4096 Mar 24 07:00 public-place/
Private Place (10 Points)¶
Tune the permissions of the ~/exam-01/private-place
directory in a
way that
You can
look and
cd
into itcreate files in it
remove files from it
Nobody else can do any of the above
Make A Backup Of ~/exam-01
(15 Points)¶
Goal
Transfer what you created (i.e. the entire contents of the remote
~/exam-01
directory) to your local machine.Use the
scp
command for this taskBut read on! Do not start!!
Think
What would be the command to do this?
Note that we were extremely picky to restrict permissions in most parts of the tree. How would you preserve those valuable permissions across the remote copy?
(Hint: read the
scp
manual page, and find out about the-p
option.)Create a file
backup-command.sh
in~/exam-01/
containing that command.Make this file executable for all users, but otherwise preserve its default permissions that it had initially.
Finally, execute the
scp
command on your local machine