Operations 12 min read

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.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux File Permissions: A Hands‑On Guide to Using chmod

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 filename

Symbolic 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_systems

2. Add write permission for the owner

chmod u+w chmod_examples

3. Add write permission for the group

chmod g+w chmod_examples

4. Add write permission for others

chmod o+w chmod_examples

5. Grant execute permission to everyone

chmod a+x linux_command.txt

6. Set full permissions using numeric mode

chmod 777 unix_command.txt

7. Remove execute permission from everyone

chmod a-x linux_command.txt

8. Change directory permissions recursively

chmod -R 777 stocks/

9. Remove read and write permissions from all users

chmod a-wx stock_trading_systems

10. 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_systems

12. Copy permissions from one file to another

chmod --reference=stock_trading_systems future_trading

These examples demonstrate how to manipulate file and directory permissions efficiently using both numeric and symbolic forms of chmod.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxUnixchmodFile Permissions
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.