While operating with file permissions in Linux, one can see that there exist numbers with chmod command: chmod 755, chmod 644, etc. The given number is expressed as some settings of permissions regarding files and directories. But that is exactly what? 🤔
Linux file permissions control who can read, write, or execute a file.
There are three categories of users for each file:
Owner | The person who owns the file. |
Group | Other users who are part of the owner’s group. |
Others | Everyone else. |
Permissions are set in three areas—read, write, and execute.
Each permission is represented by a number:
Read (r) | 4 |
Write (w) | 2 |
Execute (x) | 1 |
The numbers in the chmod
command combines these values to define permissions for the owner, group, and others.
Breaking Down 755
The number 755 in chmod 755
is divided into three parts, representing permissions for the owner, group, and others:
- The first number (7) is for the owner.
- The second number (5) is for the group.
- The third number (5) is for others.
Each number is the sum of the read, write, and execute permissions.
- 7 = 4 (read) + 2 (write) + 1 (execute) = rwx (full permissions for the owner)
- 5 = 4 (read) + 1 (execute) = r-x (read and execute for group and others)
So, chmod 755 gives full permissions (read, write, execute) to the owner and read/execute permissions to the group and others.
Other Common Permission Numbers
- 644: The owner can read and write, while the group and others can only read.
- 6 = 4 (read) + 2 (write) = rw-
- 4 = 4 (read) = r–
- 600: Only the owner can read and write; the group and others have no permissions.
- 6 = 4 (read) + 2 (write) = rw-
- 0 = No permissions
How to Use chmod
To apply these permissions, you use the chmod
command followed by the number and the file or directory name:
chmod 755 filename
This command will apply the specified permissions to the file or directory.
Understanding numeric file permissions in Linux helps you efficiently manage who can access or modify files. The numbers 755, 644, and others are simple ways to define permissions for the owner, group, and others based on read, write, and execute rights. By mastering this system, you can easily control file access on your system.