> released: 04/13, 10:30 > due: 04/19, 23:59 > > Answer the following questions. > Submit your answers to Canvas assignments. > There is an entry for this homework. > > > 1. Linux dir permissions (8 points) > > In Linux, each file/dir has its access control list (ACL). > That's what we know as "permissions". > > To check permissions: > - one can use "ls -l file" to see a file's permissions > - one can use "ls -ld dir" to see a dir's permissions > > To change permissions: > - set "r--------" by "chmode 0400 dir" (4 in oct-num means '100') > - set "-w-------" by "chmode 0200 dir" (2 in oct-num means '010') > - set "--x------" by "chmode 0100 dir" (1 in oct-num means '001') > > Now, run the following cmds and answer questions below. > > $ mkdir /tmp/dir1 > $ touch /tmp/dir1/file1 > $ touch /tmp/dir1/file2 > $ mkdir /tmp/dir1/dir2 > > 1.a (2 points) understanding 'r' > Run the following cmds: > > $ chmod 0400 /tmp/dir1 > $ ls /tmp/dir1 > > What do you see? > Write down the output and explain why in 1--2 sentences. > [answer: you will see something like: file1 file2 dir2 ls: fts_read: Permission denied Because of read permission, you can read names that exist in this dir. But without 'x', you cannot read the inode of file1 and file2 so "ls" reports an error. ] > > > 1.b (2 points) understanding 'w' > Run the following cmds: > > $ chmod 0200 /tmp/dir1 > $ touch /tmp/dir1/file3 > > What do you see? > Write down the output and explain why in 1--2 sentences. > [answer: you will see something like: touch: /tmp/dir1/file3: Permission denied because to create a file under dir1, you need to be able to manipulate inodes inside an dir, which requires 'x'. To see this, try: $ chmod 0300 /tmp/dir1 $ touch /tmp/dir1/file3 (you should not see any problem.) (see also: https://piazza.com/class/lcjlveo7nbi73q/post/228) [update 04/20: the reason blow is incorrect; depending on implementation, fs may not have to **read** to find empty slots, which don't require to read the contents.] // because to create a file under dir1, you need to find // an empty slot in dir's contents (the name-to-inum table) // which requires the read permission, 'r'. ] > > > 1.c (2 points) understanding 'x' I > Run the following cmds: > > $ chmod 0100 /tmp/dir1 > $ ls /tmp/dir1 > > What do you see? > Write down the output and explain why in 1--2 sentences. > [answer: you will see something like: ls: /tmp/dir1: Permission denied this is because to list all files in a dir, you need to read its name-to-inum table, which require read permission, 'r'. ] > > 1.d (2 points) understanding 'x' II > Now, run the following cmds: > > $ chmod 0100 /tmp/dir1 > $ touch /tmp/dir1/dir2/file4 > $ ls /tmp/dir1/dir2/ > > What do you see? > Write down the output and explain why in 1--2 sentences. > [answer: you will see something like: file4 (without errors) this is because 'x' allows you to access the inode under "dir1" and you have all permissions (usually "rwx" for file owner) in "dir2". You can also try "cd /tmp/dir1/dir2/" and you can do whatever you want under "dir2". ] > > > 2. Feedback (2 points) > > This is to gather feedback. Any answer, except a blank one, will get points. > > > 2.a Please state the topic or topics in this class that have been least clear to you. > > > 2.b Please state the topic or topics in this class that have been most clear to you. > > > 3.c (optional) anything you'd like us to know?