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 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 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.
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.
Now, run the chmod 755 command and execute the ls -l command again.
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 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.
|character special file
|block special file
|Allow user to open file and read
|Allow user to write in file
|Treat file as executable and allow user to run it
Access permission works differently for directories.
|The user can check the directory contents if execute permission is also set.
|The user can create, delete, and rename files if the execute permission is also set.
|user can enter into this directory for example, cd directory name