Blame

51f3df Niklas Polke 2026-08-05 22:24:08
Create CHMOD
1
# CHMOD
2
3
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.
4
5
## Numeric (Octal) Notation
6
7
Each permission is represented by a number:
8
```
9
4 = Read (r)
10
2 = Write (w)
11
1 = Execute (x)
12
```
13
14
The values are added together for each user category:
15
```
16
Owner
17
Group
18
Others
19
```
20
21
Example: `chmod 755 script.sh`
22
23
This results in:
24
```
25
Owner: rwx (7 = 4+2+1)
26
Group: r-x (5 = 4+1)
27
Others: r-x (5 = 4+1)
28
```
29
30
## Symbolic (Letter) Notation
31
32
Permissions can also be modified using letters:
33
```
34
u = User (owner)
35
g = Group
36
o = Others
37
a = All users
38
```
39
40
Operators:
41
```
42
+ = Add permission
43
- = Remove permission
44
= = Set exact permission
45
```
46
47
Examples:
48
```
49
chmod u+x script.sh # Add execute permission for the owner
50
chmod g-w file.txt # Remove write permission from the group
51
chmod a=r file.txt # Set read-only permission for everyone
52
```
53
54
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.