ERODD HOME

Operating Systems CPSC 304
Earl Rodd erodd@malone.edu Extension 8546 www.malone.edu/erodd
LINUX Permissions Lab
Name: __________________________________________

Lab Functions

  1. Create a simple file named "try" with just an "echo" command like this:
    Important: Use either the /home/square (default) directory or "cd /tmp" to use the /tmp directory. Do not use your hdrive. Network drives do not support permissions normally!
    echo echo Here in try > try
    
  2. Attempt to execute your "try" command:
    try
    
    What happens? __________________________

  3. What are the permissions of file try? (use "ls -l try")

    Owner: _______

    Group: _______

    Other: ______

  4. Add execute permission for the owner (ourself).
      chmod u+x try
    
  5. Display permissions again. What changed? _____________________

  6. Attempt to execute the file again (it is a script).
    try
    
    What happened this time? _________________________

  7. Add a line to the file with:
    echo echo Second command >> try
    
  8. Execute the "try" command again. What happens? _______________

  9. Remove write permission for the user.
    chmod u-w try
    
  10. Now attempt to add a third line to the file:
    echo echo Third one >> try
    
    What happens? _____________________

  11. Check the permissions of the "grep" command file. The name is /bin/grep.

    Who owns the file? ________________________

    What are the permissions for other users (like you)? __________

    Can you write to the file? _________________ (you can try with "echo junk >> /bin/grep").

  12. Make /tmp your current directory. We will create some files and work with permissions.

    Now make a new subdirectory in /tmp named /tmp/ptest. (e.g. if /tmp is your current directory, mkdir ptest).

    Make /tmp/ptest your current directory.

  13. Create a file named /tmp/ptest/p1 using echo or vi.

    What userid owns the file? _______________________

    What group has group ownership of the file? _____________________

  14. Make the permissions on the file 600 (6=rw) with:
    chmod 600 p1
    
    See text for use of numeric permissions.

  15. Prove to yourself that you can read (e.g. vi) and write (e.g. echo with >> or vi and save) the file.

  16. Change the owner of the file p1 to "extra". Try the chown command without sudo. What happens? ___________________________

    Now use sudo to change ownership of p1 to "extra". (e.g. sudo chown extra p1.

  17. Use ls -l to verify ownership. What are the permissions?

    ________________________

  18. Try to read from the file p1 (using (cat or vi).

    What happens? __________________________

  19. Try to write to the file p1 (using echo or vi).

    What happens? __________________________

  20. Do these functions. Write the command you use for each function:

    1. Make /tmp your current directory: ________________________

    2. Make a new directory in /tmp: _________________________

    3. Make the permissions on the directory drwxr--r-- _____________________________________

    4. Change the ownership of the directory to userid "extra". ___________________________________________

    5. Try to make your new directory the current directory.

      Command: ______________________________

      What happens: ____________________________________

    6. Change the permissions on the directory to drwxr-xr-x (you will need to use sudo since your userid, "square", is no longer the owner). ____________________________________

    7. Now make the directory your current directory. ___________________________

    8. Try to create a file (e.g. vi or echo) in this directory. _________________________________

      What happens? _____________________________________

      Why? ____________________________________

To Turn in

This handout with answers filled in (handwritten).