Permissions and Security
Linux File Permission Fundamentals
Linux implements a robust security model through file permissions and ownership, controlling access to files and directories at granular levels.
Permission Types and Representation
graph LR
A[Permission Types] --> B[Read]
A --> C[Write]
A --> D[Execute]
Permission Representation
Symbol |
Meaning |
Numeric Value |
r |
Read |
4 |
w |
Write |
2 |
x |
Execute |
1 |
Basic Permission Commands
## View file permissions
ls -l file.txt
## Change file permissions
chmod 755 script.sh
## Change file ownership
chown user:group file.txt
Permission Modification Techniques
## Add execute permission
chmod +x script.py
## Remove write permission
chmod -w document.txt
## Set specific permissions
chmod u=rwx,g=rx,o=r file.txt
Advanced Permission Scenarios
## Recursive permission change
chmod -R 644 /home/project
## Change ownership recursively
chown -R user:group /shared/directory
Permission Numeric Calculation
## Permission calculation
## 7 = 4(read) + 2(write) + 1(execute)
## 5 = 4(read) + 1(execute)
## 4 = 4(read)
chmod 754 important_script.sh
These commands demonstrate comprehensive file permission management in Linux systems.