Master Linux File Permissions: A Hands‑On Guide to Using chmod
This tutorial explains how to view and modify Linux/Unix file permissions using the chmod command, covering numeric and symbolic modes, common options, and multiple practical examples ranging from simple read‑only settings to recursive directory permission changes.
Introduction
The chmod command changes file permissions in Linux and Unix systems, and its usage is identical across both platforms.
Understanding Permission Strings
Running ls -l displays a string such as -rwxrwxrwx, where three groups of three characters represent the permissions for the owner, group, and others respectively (read r, write w, execute x).
Numeric (Octal) Mode
Permissions can be set numerically: r = 4, w = 2, x = 1. The sum of the values for each group yields a digit between 0 and 7. For example, -rwxrw-r-- corresponds to 764.
chmod 764 filenameSymbolic Mode
The symbolic format is chmod USER OPTION AUTHORITY FILE where:
USER : u (owner), g (group), o (others), a (all)
OPTION : + (add), - (remove), = (set exactly)
AUTHORITY : r, w, x Multiple specifications are separated by commas without spaces.
Common Options
-v, --verbose: report each processed file -c, --changes: report only when a change is made -f, --silent, --quiet: suppress most error messages -R, --recursive: apply changes recursively to directories
Practical Examples
1. Make a file read‑only for the owner
chmod 400 stock_trading_systems2. Add write permission for the owner
chmod u+w chmod_examples3. Add write permission for the group
chmod g+w chmod_examples4. Add write permission for others
chmod o+w chmod_examples5. Grant execute permission to everyone
chmod a+x linux_command.txt6. Set full permissions using numeric mode
chmod 777 unix_command.txt7. Remove execute permission from everyone
chmod a-x linux_command.txt8. Change directory permissions recursively
chmod -R 777 stocks/9. Remove read and write permissions from all users
chmod a-wx stock_trading_systems10. Add execute permission only to directories (capital X )
chmod a+X *11. Add execute permission to owner and group
chmod u+x,g+x stock_trading_systems12. Copy permissions from one file to another
chmod --reference=stock_trading_systems future_tradingThese examples demonstrate how to manipulate file and directory permissions efficiently using both numeric and symbolic forms of chmod.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
