chmod 755 linux command is used for changing permissions for the files and directories. Only the file's owner or superuser can change the file access permissions.
chmod 755 command does following work:
- It gives read, write and execute (RWX) file permissions to file owner,
- It gives read and execute (R_X) file permissions to file's group owner and other system users.
- It removes write permissions from both file's group owner and other users.
Number after the chmod 755, is actually an octal number. First number 7 (4+2+1) represents 4-read, 2-write, and 1-execute permissions. Second and third number 5 (4+1) represents 4-read and 1-execute permissions
Octal number is a number system and It only has 8 digits starting from 0 to 7. That's mean we can only use numbers from 0 to 7 to make any number.
chmod 755 verify
To verify 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 touch linux command named chmod_verify.txt and check it's permissions.
In the above screenshot, first 1 character in "-rw-rw-r--" represents file type and rest nine characters represent file permissions for the file's owner, file's group owner and everybody.
Now, run the chmod 755 command and executel ls -l command again.
In the above screenshot, below work has happened.
- 4 character is changed to x, means file's owner got the execute permissions.
- 6 character w is removed now, means file's group owner write permission is removed and,
- 7 character x is changed from -, that means file's group owner got the execute permissions.
- 10 character is also changed from - to x, means everybody got the execute permision.
|c||character special file|
|b||block special file|
|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 work differently for directories.
|r||User can check the directory contents if execute permission is also set.|
|w||User can create, delete and renamed files if the execute permission is also set.|
|x||User can enter into this directory for example, cd directoryname|