Assignment 4

Locks and Keys

Assigned
Due

Oct 11
40 pts
Oct 25

For this assignment, you must work on Sandbox. You will create some files there, and I'll just go look at them. On Sandbox, you have all been added to the group cs231. Log on to Sanbox and go to the directory /var/cs231. You will find directories named after each of your accounts, which I refer to as your directory, even though you don't own it. But you can create files there. There is also a directory PUBLIC.

  1. Examine the ownership and permission settings for /var/cs231, /var/cs231/PUBLIC and your directory under cs231.
  2. Create a text file in your directory which only you can read or write. (And root, who can always read anything regardless.) Give a sentence or two about why you can create this file even though you don't own the directory.
  3. In your directory, create another text file which contains a short public greeting, and can be read (but not written) by any ordinary user on the system.
  4. Create a file comments in your directory which is writable by the members of the class, but not by others.
  5. See if anyone else has gotten around to creating comments. Go to their directory and add some text to their comments file, including your name. Please add to to it without destroying the previous contents. (Linux won't stop you, though; Unix does not have a separate append permission.) If you find that someone else's comment file won't allow you write, you can send that user an email and ask them to fix it.
  6. In your directory, create a file with exactly these contents:
    echo I am running! Yey!
    Make this file readable and executable by you and anyone in class, but not users at large. Only you should be able to write it. Execute it by typing the file name, preceded by ./
  7. Go to someone else's directory and try to create a file there. You won't be able to. Do you see why?
  8. Go to /var/cs231/PUBLIC and create a text file which can be read by the members of this class, and no one else. It should not be writable by anyone but you. Give some short greeting to the class.
  9. Create a second file in PUBLIC which you can read or write, but has no other permissions. Explain why you are allowed to create this file, but cannot do so in one of the other student's directories.
  10. Go to your directory and create a subdirectory. Set it so that members of the class can list the directory and access files in it, but other users can only access files if they already know the name (they can't list the directory). You should be able to list the directory and acces files there, but also create, delete or rename the files, which no one else can do.
  11. Create two small text files in this subdirectory, of whatever content (but not empty). Set them writable by you only, and one readable by class members only, the other readable by everyone.