File Permissions

Key Goals

  • Listing file permissions
  • Modifing standart file permissions
  • Changing the default system permissions
  • Changing file ownership

Content

Listing permissions:
  • stat
Changing default system permissions:
  • umask
File permissions:
  • chmod
  • Sticky bit
  • GroupID bit
  • UserID bit
  • getfacl
User permissions:
  • chown
  • chgrp
  • id
  • primary and secondary groups

Exercises

  1. The following prints the file permission of the /etc/host file:

    -rw-r--r--. 1 root root 288 Oct 25 23:20 /etc/hosts
    
    • Explain the file permission structure.
    • Which parameter indicates us about the type of a file?
    • Which file types are exists in the linux environment?
  2. Use stat to examine the ‘/etc/hosts’ it full file permissions.

  3. Which command will set our default system permissions into 640 (use umask)?

  4. Which command will ser our default system permissions into -rw——- (use umask)?

  5. Are the file system permission cumulative? explain what is a cumulative permissions.

  6. Explain what is the sticky bit? and what it controls?

  7. Explain the usage of the GroupID and UserID bit.

  8. Run ‘ls -l /usr/bin/passwd’, explain it’s file permissions.

  9. List all the user’s groups using the id command.

  10. Explain the purpose of the ‘wheel’ group in a linux evironment.

  11. Why there is a seperation to a primary and secondary groups, why it can not be just a set of groups?

  12. How can we change our primary group?

  13. How would you change the user and group ownership for all the content of a directory (recursively).

  14. Are the permissions copied when someone copies a file? how can we control that?

  15. Which kind of permissions are needed in order to copy some file from it’s current location to a new one?

  16. How would you add permissions to a specific user?

  17. Scenario:
    • Inside your local home directory, create a stickydir directory with a sticky bit on.
    • Inside stickydir, create file1 file that contains the following content: “Hello World”.
    • Change the permissions to -rw——- (use the numeric notation).
    • Add an execute permissions to the group (use the symbolic notation).
    • Set ‘no permissions’ to others (use ‘=’ sign).
    • Change file’s group to ‘wheel’.
    • Give the user charlie read persmissions on the file without changing the file owner or group.