🔹 1.
Understanding chmod command
chmod (change mode) is used in Unix/Linux to change file or directory
permissions.
Each file has three types of users:
1. User (u) – the owner of the file
2. Group (g) – users who are part of the file’s group
3. Others (o) – everyone else
And each can have three permissions:
Permission Symbol Numeric Value Meaning
Read r 4 Can view contents
Write w 2 Can modify contents
Execute x 1 Can execute the file (or access directory)
🔹 2. Numeric (Octal) Notation
Each permission set (user, group, others) is represented by a single digit — the
sum of the values of the permissions assigned.
Permission Combination Calculation Value
Read only 4 4
Write only 2 2
Execute only 1 1
Read + Write 4+2 6
Read + Execute 4+1 5
Read + Write + Execute 4 + 2 + 1 7
🔹 3. Syntax
chmod [permissions] filename
Example with octal value:
chmod 755 [Link]
This means:
User (owner): 7 = 4+2+1 (rwx)
Group: 5 = 4+0+1 (r-x)
Others: 5 = 4+0+1 (r-x)
🔹 4. Real-time Examples
🧩 Example 1: Full permission to everyone
chmod 777 [Link]
✅ User, Group, Others = rwx
Everyone can read, write, and execute the file.
⚠️Risky — use carefully, especially for scripts or system files.
🧩 Example 2: Read + Write for owner, Read-only for others
chmod 644 [Link]
✅ User = rw- (6)
✅ Group = r-- (4)
✅ Others = r-- (4)
Common for text files that only the owner edits, but others can read.
🧩 Example 3: Executable script for owner only
chmod 700 [Link]
✅ User = rwx (7)
✅ Group = --- (0)
✅ Others = --- (0)
Only the owner can run or modify this script.
🧩 Example 4: 421 notation in detail
Let’s break down a few numeric codes:
Code Binary (rwx) Meaning
4 100 Read only
2 010 Write only
1 001 Execute only
6 110 Read + Write
5 101 Read + Execute
7 111 Read + Write + Execute
So if you write:
chmod 421 [Link]
This means:
User = 4 → r-- (read only)
Group = 2 → -w- (write only) (unusual)
Others = 1 → --x (execute only)
✅ In real life, chmod 421 is rare, but it helps understand how 4, 2, and 1 values
combine.
🔹 5. Example Verification
After changing permission, check using:
ls -l [Link]
You might see output like:
-rw-r--r-- 1 munish users 120 Oct 06 09:40 [Link]
This corresponds to:
User: rw-
Group: r--
Others: r--
Which equals 644.