The chmod 755 linux command is used for changing permissions for files and directories. Only the file’s owner or superuser can change the file access permissions.
The chmod 755 command does the following work:
- It gives read, write, and execute (RWX) file permissions to the file owner.
- It gives read-and-execute (R_X) file permissions to the file’s group owner and other system users.
- It removes write permissions from both the file’s group owner and other users.
The number after the chmod 755 is actually an octal number. The first number 7 (4+2+1) represents 4-read, 2-write, and 1-execute permissions. second and third numbers (4+1) represent 4-read and 1-execute permissions
Octal Number
Octal number is a number system, and it only has 8 digits starting from 0 to 7. That means we can only use numbers from 0 to 7 to make any number.
Octal numbers: 0,1,2,3,4,5,6,7
chmod 755 verify
To verify whether chmod 755 is executed successfully or not,. You can use the below command.
ls -l
Let’s take an example. We first create a sample file using a touch Linux command named chmod_verify.txt and check it’s permissions.
In the above screenshot, the first character in “-rw-rw-r–” represents file type, and the rest of the nine characters represent file permissions for the file’s owner, the file’s group owner, and everybody else.
File/Directory | Owner | Group | Everybody |
---|---|---|---|
– | rw- | rw- | r– |
Now, run the chmod 755 command and execute the ls -l command again.
File/Directory | Owner | Group | Everybody |
---|---|---|---|
– | rwx | r-x | r-x |
In the above screenshot, the below work has happened.
- 4 characters are changed to x, which means the file’s owner got the execute permissions.
- 6 character w is removed now, which means the file’s group owner’s write permission is removed.
- 7 character x is changed from -, which means the file’s group owner got the execute permissions.
- 10 characters are also changed from – to x, which means everybody got the execute permission.
Attribute | File Type |
---|---|
– | regular file |
l | symbolic link |
d | directory |
c | character special file |
b | block special file |
Attribute | File Permissions |
---|---|
r | Allow user to open file and read |
w | Allow user to write in file |
x | Treat file as executable and allow user to run it |
Access permission works differently for directories.
Attribute | Directory Permissions |
---|---|
r | The user can check the directory contents if execute permission is also set. |
w | The user can create, delete, and rename files if the execute permission is also set. |
x | user can enter into this directory for example, cd directory name |