Permission Management
Understanding Linux Permissions
Permission Types
Linux uses three primary permission types:
- Read (r)
- Write (w)
- Execute (x)
Permission Levels
Permissions are set for three user categories:
Permission Representation
graph LR
A[Permission Representation] --> B[rwx rwx rwx]
B --> C[Owner Group Others]
Viewing Permissions
## List file permissions
ls -l /home/user/documents
Permission Numeric Representation
Numeric Value |
Permission |
4 |
Read |
2 |
Write |
1 |
Execute |
Changing Permissions
Using chmod Command
## Change file permissions
chmod 755 filename
## Change directory permissions
chmod 700 directory_name
Symbolic Permission Modification
## Add execute permission for owner
chmod u+x filename
## Remove write permission for group
chmod g-w filename
Advanced Permission Management
Special Permissions
Symbol |
Meaning |
Numeric Value |
setuid |
Run as file owner |
4 |
setgid |
Inherit group permissions |
2 |
Sticky bit |
Restrict file deletion |
1 |
Setting Special Permissions
## Set setuid permission
chmod u+s filename
## Set sticky bit on directory
chmod +t directory_name
Permission Verification
## Check effective permissions
namei -l /path/to/file
Best Practices
- Follow principle of least privilege
- Regularly audit file permissions
- Use groups for access management
Note: LabEx recommends practicing permission management in a controlled environment to ensure system security.