CSCI-UA.0480 Spring 2016 Homework 2: Exercises in Permissions


Handed out Tuesday, February 23, 2016
Due 5:00 PM, Thursday, February 25, 2016

Homework 2: Exercises in Permissions

The following exercises are designed to give you exposure to various POSIX commands that can be used to set/change permissions. Log on to the virtual dev box as user httpd to get started. Answer the following questions in a text file.


At the terminal, do

$ mkdir ~/hw2 && cd ~/hw2
$ echo 'hello' > a.file
$ ls -l a.file
$ stat a.file
Question 1: What are the permissions set to for this file?

These are the "default" permissions. You can learn more about how default permissions are set and determined by exploring the umask command, man umask.

Now do

$ cat a.file
$ chmod 000 a.file
Question 2: After you have run the chmod command, what will be the behavior of cat?
# Notice how even though you don't have write permissions,
# you can still remove the file:
$ rm a.file
$
Question 3: Why is this allowed? What structure does rm modify?
$ rm -f *
$ echo "Though this be madness, yet there is method in't." > h2.2
$ ls -l h2.2
$ chmod g-w h2.2
$ chmod o-rwx h2.2
$ sudo chown irc: h2.2
Question 4: What is the current state of the file: Who can edit it? Who can read it?
$ sudo chown httpd:irc h2.2
Question 5: Now what is the state of the file? What has changed about its state from the previous question?
$ mkdir restrict
$ ln h2.2 restrict/secret
$ ls -l
# Notice the first letter in the bits indicates restrict is 
# a directory, not a file. Further, notice how all of the
# executable bits are set.
$ chmod -x restrict
$ ls -l restrict
Question 6: What happens if I try to cd into restrict? What about editing the restrict/secret file?

Handing in the homework

Use NYU Classes; there's an entry for this homework.


Last updated: 2016-04-15 16:24:03 -0400 [validate xhtml]