[Linux] - Managing Permissions and Ownership
[Linux] - Managing Permissions and Ownership
Topic A: Modify File and Directory Permissions
Permissions
Chmod Command
Chmod symbolic mode
# chmod 764 file1: user=rwx; group=rw; others=r
# chmod 700 file1: user=rwx; group =-, others =-
# chmod 640 file1: user =rw; group =r, others =-
TOPIC B: Modify File and Directory Ownership
chown
TOPIC C: Configure Special Permissions and Attributes
SYNTAX
The following is the syntax for setting the SUID on a file, using symbolic and absolute mode, respectively:
# chmod u+s {file names}
# chmod 4### {file names}
SGID (Set Group ID): is the permission that allows a user to have similar permissions as the group owner of the file
The following is the syntax for setting the SGID on a directory, using symbolic and absolute mode, respectively:
# chmod g+s {directory names}
# chmod 2### {directory names}
Removing the SUID and SGID is as simple as using the - (minus) operator in symbolic mode, or setting the first permission bit to 0 in absolute mode.
Sticky bit
The syntax for setting the sticky bit is as follows, using symbolic mode and absolute mode, respectively:
# chmod +t {directory names}
# chmod 1### {directory names}
Immutable flag
getfacl
setfacl
TOPIC D: TROUBLESHOOTING
Permissions Troubleshooting
- The owner of a text file is denied permission to view the contents of the text file => use chmod to grant read privileges to the owner context
- A user is denied permission to remove a directory, despite having a write permission => use chmod to add execute permissions to the directory for the appropriate context
- A user is denied permission to enter into a directory, despite having read permission => use chmod to add execute permission to the directory for the appropriate context
- A user is denied permission to remove a file, despite having full permission on that file => use chmod to add write permission to the directory for the proper context
- A user is denied permission to create files in a directory they have write and execute permission to => use chattr to remove the immutable flag
- The root user is denied permission to modify a file => use chattr to remove the immutable flag
- All users have the ability to list the contents of a directory, when only the owner, group members, and a specific service account should => The read permission is set on the directory for the others context. Add the service account to the directory's ACL using the setfacl command, granting the account read access
- A user is denied permission to execute a script that they themselves created => use chmod to add execute permission to the script for the file owner
- A user is denied permission to execute a script, despite having execute permission => Use chmod to add read permission to the script for the appropriate context
- All users are able to delete a file, but they should be able to write to it => By default, the write and execute permissions on directories enable users to delete the objects therein. Add the sticky bit permission to the container directory so that only the owner or root can delete the file.
Ownership Troubleshooting
- A user is unable to access a file, despite the owner context having full permissions => Use the chown command to make the user the owner of the file
- A user is unable to delete a file, despite the containing directory granting full permissions to the group => Use the chgrp command to make the directory's owning group the same as the user's
- Several users are able to modify a file despite the others context only having read permission => Use chgrp to change the file's owning group to some other group
- When a user creates files in a shared directory, the files take on the user's group ID, when they should take on the directory's group ID => Use chmod to set the SGID permission on the containing directory
- When a user creates files in shared directory, the files take on the directory's group ID, when they should take on the user's group ID => Use chmod to remove the SGID permission on the containing directory
Comments
Post a Comment