CHMOD

The chmod command is used to change file and directory permissions in Linux and Unix-based systems. Permissions can be specified using either numeric (octal) or symbolic (letter) notation.

Numeric (Octal) Notation

Each permission is represented by a number:

4 = Read (r)
2 = Write (w)
1 = Execute (x)

The values are added together for each user category:

Owner
Group
Others

Example: chmod 755 script.sh

This results in:

Owner: rwx (7 = 4+2+1)
Group: r-x (5 = 4+1)
Others: r-x (5 = 4+1)

Symbolic (Letter) Notation

Permissions can also be modified using letters:

u = User (owner)
g = Group
o = Others
a = All users

Operators:

+ = Add permission
- = Remove permission
= = Set exact permission

Examples:

chmod u+x script.sh      # Add execute permission for the owner
chmod g-w file.txt       # Remove write permission from the group
chmod a=r file.txt       # Set read-only permission for everyone

Both notations achieve the same result. Numeric notation is commonly used for setting complete permission sets, while symbolic notation is useful for modifying specific permissions.

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9