chmod Symbolic Mode
chmod changes file permissions. The symbolic mode uses letters - it's human-readable and flexible.
Basic Syntax
chmod [who][operation][permission] file
- who: u (owner), g (group), o (others), a (all)
- operation: + (add), - (remove), = (set exactly)
- permission: r (read), w (write), x (execute)
Adding Permissions
u+x = add execute permission for owner.
Removing Permissions
o-r = remove read permission from others.
Setting Exact Permissions
= sets exactly these permissions, removing any others.
Common Examples
Make Script Executable
Without specifying who, +x adds execute for all classes.
Remove All Access for Others
o= with no permissions removes all access for others.
Give Group Read/Write
Make Private (Owner Only)
go= Shorthand
go= means "group and others, set to nothing." It's a quick way to remove all non-owner permissions.
Multiple Changes at Once
Separate multiple changes with commas.
Recursive Changes
-R applies changes recursively to all files and subdirectories.
Careful with -R
Recursive changes affect everything. Be specific about what you're changing. chmod -R 777 / is a disaster.
Reference Another File
Copy permissions from one file to another.
Real-World Scenarios
Downloaded Script Won't Run
Shared Project Directory
Secure Config File
What does `chmod u+x,go-w file` do?
Quick Reference
| Command | Effect |
|---|---|
chmod +x file | Add execute for all |
chmod u+x file | Add execute for owner |
chmod g+w file | Add write for group |
chmod o-rwx file | Remove all for others |
chmod u=rw,go=r file | Set owner rw, everyone r |
chmod -R g+w dir/ | Recursive group write |
Key Takeaways
- Symbolic mode:
[who][+/-/=][permissions] +adds,-removes,=sets exactlyu= owner,g= group,o= others,a= all- Combine with commas:
u+x,g+w -Rfor recursive changes (use carefully)
Next: chmod numeric mode - the faster way.