Help & Tutorial
Master Linux permissions with comprehensive examples and explanations
Quick Navigation
Understanding File Permissions
What Are File Permissions? π€
File permissions in Linux control who can do what with files and directories. Think of them as rules that determine:
- Who can access the file (owner, group, others)
- What they can do with it (read, write, execute)
The Three Permission Types π
The Three User Types π₯
Owner (u)
The user who owns the file. Usually the person who created it.
Group (g)
Users who belong to the file's group. Great for team collaboration.
Others (o)
Everyone else on the system. Be careful with these permissions!
Reading Permission Strings π
- First character: File type (- = file, d = directory, l = link)
- Next 3 characters: Owner permissions (rwx = read, write, execute)
- Next 3 characters: Group permissions (r-x = read, execute only)
- Last 3 characters: Others permissions (r-- = read only)
Interactive Permission Calculator
Enter Octal Permissions:
Owner
Group
Others
Result:
Quick Presets:
Real-World Examples
Making Scripts Executable
Use case: Deployment scripts, build scripts, any file you need to run
Securing SSH Keys
Use case: Private keys should be owner-only, public keys can be readable
Configuration Files
Use case: Config files that services need to read but only admins should edit
Database Files
Use case: Database files should be private, backup scripts executable by owner and group
Docker & Containers
Use case: Container entry points need to be executable, Dockerfiles are just text
Secrets & Credentials
Use case: Any file containing passwords, API keys, or sensitive data
DevOps Scenarios You'll Encounter
Problem:
Your build pipeline fails because scripts don't have execute permissions.
Solution:
Lesson: Always check script permissions in your CI/CD setup!
Problem:
Security scan finds files with overly permissive permissions.
Solution:
Lesson: Private keys and secrets should always be 600!
Problem:
Container won't start because entrypoint script isn't executable.
Solution:
Lesson: Set permissions before building Docker images!
Problem:
Kubernetes secrets mounted with wrong permissions, causing security issues.
Solution:
Lesson: Always secure mounted secrets in K8s!
Ultimate Chmod Cheat Sheet
Common Octal Permissions
| Octal | Symbolic | Use Case |
|---|---|---|
755 |
rwxr-xr-x |
Scripts, executables |
644 |
rw-r--r-- |
Regular files, configs |
600 |
rw------- |
Private keys, secrets |
750 |
rwxr-x--- |
Group-executable scripts |
700 |
rwx------ |
Private directories |
777 |
rwxrwxrwx |
β οΈ Dangerous - avoid! |
Symbolic Notation Quick Reference
| Command | Effect |
|---|---|
chmod +x file |
Add execute for all |
chmod u+rwx file |
Owner gets all permissions |
chmod go-w file |
Remove write from group & others |
chmod a=r file |
Everyone gets read only |
chmod u=rwx,go=rx file |
Owner: rwx, others: rx |
chmod -R 755 dir/ |
Recursive permission change |
u= owner (user)g= groupo= othersa= all (u+g+o)+= add permission-= remove permission== set exact permission
Ready to Practice?
Now that you understand the concepts, let's put your knowledge to the test!
π‘ Pro Tips for the Game:
- Read the scenario carefully - context matters!
- Think about security - who really needs access?
- Both octal (755) and symbolic (+x) commands work
- Use hints if you're stuck - learning is the goal!
- Try different approaches - there's often more than one solution