FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

Setting default permissions


Notes:

Every new file or directory that you create will have some set of default permissions assigned to it. You can set what these permissions will be with the umask command.

Notes on umask:

  1. The umask command can be used to set default permissions for any new file that is created; it will not reset the permissions for existing files.
     
  2. On the linux filesystem, files cannot be set executable by default.
     
  3. Umask determines which permissions are NOT allowed; it is the opposite of chmod. The command: umask 026 gives:
    permissions for the user are 0 = 000 binary
    read allowed, write allowed, execute allowed
    permissions for the group are 2 = 010 binary
    read allowed, write NOT allowed, execute allowed
    permissions for others are 6 = 110 binary
    read NOT allowed, write NOT allowed, execute allowed
     
  4. If the umask is 026, a new directory will have permissions: rwxr-x--x
     
  5. If the umask is 026, a new file will have permissions: rw-r-----
    (the execute permissions are not turned on automatically)


Exercise:

  1. What is your current umask value? (enter the command: umask)
     
  2. Use the mkdir command to make a new directory. What are the permissions for this directory? ____________________
     
  3. Use the touch command to create a new file. What are the permissions for this file? ____________________
     
  4. Set the umask to 022.
     
  5. Use the mkdir command to make a new directory. What are the permissions for this directory? ____________________
     
  6. Use the touch command to create a new file. What are the permissions for this file? ____________________
     
  7. Change your umask so that the default permissions for any directory that you create are rwx------. What is the umask? ____________________
     
  8. Create a new directory. Verify that the umask worked.
     
  9. With this umask, what are the permissions for a new file? ____________________


Questions & Answers:

  1. What command will change the permissions on the existing file readme to rw-rw-r--?
     
    Answer:  chmod 664 readme
     
  2. Assume that the "new" directory does not exist. The following commands are executed:
         umask 027 ; mkdir new
    What are the permissions for the new directory?
     
    Answer:  rwxr-x---
     
  3. Assume that "newfile" does not exist. The following commands are executed:
         umask 027  ;  touch newfile
    What are the permissions for the new file?
     
    Answer:  rw-r-----

Copyright © L.M.MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next