In the Linux system to add permissions to the file or any folder chmod command is used, not only that there are numbers assigned, based on the types of permissions like for read its 4 for write its 2 and for execution its 1 which collectively makes the number 7.
So, in simpler words chmod 777 means granting all permissions to read, write and to execute any file by any user of the system, to read more about the chmod 777 read this guide as it explains its meaning in detail.
Giving Permissions to a File in Linux
To deeply understand the meaning of chmod 777 one must be fully aware of how to give permissions to a file or a folder. There are three types of permissions that are normally given to the file one is read, write and third is execute and to make the permission understandable by the computer each type has been assigned a number:
0 | No permission |
1 | Permission to execute |
2 | Permission to write or modify |
3 | Permission to write and execute |
4 | Permission to read |
5 | Permission to read and execute |
6 | Permission to read and write |
7 | Permission to read, write and execute |
There are three types of users in Linux: one is Owner, second is Group and third is Others and the chmod 777 means that all the users can read, write, or execute the file. To further illustrate setting the permissions using the chmod command the table below gives three-digit combination:
Permissions | Values |
No permission for read, write, and execute | 0(0+0+0) |
Permission to only execute | 1(0+0+1) |
Permission to only write | 2(0+2+0) |
Permission to only read | 4(4+0+0) |
Permission to read and execute | 5(4+0+1) |
Permission to read and write | 6(4+0+2) |
Permission to read write and execute | 7(4+2+1) |
For illustration, there is an example of changing the permissions of a file using chmod. It has been done for you to deeply understand the meaning of chmod 777.
Let’s create a simple bash script file on Linux system and then change the permissions accordingly using:
Next add any script in the bash file and close the file by saving it:
Now we will add some permission to the file like if you want that no one can access this file then use:
Now just to check let’s try to read it using:
From the above image one can clearly understand that now one can read file except the user with sudo privileges; now check the file if it is editable or not using:
From the above image one can clearly understand that no one can write or modify. Now see if this file is executable using:
From the above image is is abundantly clear that nobody other than system administrators can run the file, now let’s change the permission of the file that everyone can view it using the chmod:
One may tell from the image above that the permission has changed because the file’s color has changed to green.which means everyone can read, write, and execute the file so let’s try out reading the .sh file:
Now you can see that the file is readable so now let’s write or modify the file using:
The file is also now writable as well, now the last thing that is needed to be checked is the file execution and it can be done by:
The file is now executable as well so now you must have mustered the use of chmod 777 in Linux and to summarize it can be said it makes the file readable, writeable, and executable for everyone on the Linux system.
Conclusion
Setting permissions for accessing the data of your Linux system is beneficial as it keeps the data safe from hackers. The chmod command is used for such purposes. The chmod 777 is mainly used to make the file readable, writable, and executable for any user.