Chmod 777 is the detail, the specific setting that opens the door to a file or document. The larger picture, a major part of the landscape, is file permission. The concept is quite simple, really. In Unix systems, there is a control process that is used to permit or deny access to a file. Users of Mac OS X and Linux may encounter this obstacle if they try to upload a file or make some modification to a document. The system will display a message stating that the user does not have permission to upload the file.
The letters chmod are a shortened form of “change mode,” with a series of numbers following that give further details as to the issue the user has encountered. The idea behind “change mode” is clear enough but many people have little or no idea what the string “777” means. To get to that point, it may be best to get an overall view of file permissions and how they can be set and reset.
Basically, there are two distinct parts to the controls for files – Classes and Permissions. The Classes are the method that determines who will be able to access a file. Permissions are the specific action a user can take with that same file. When setting the controls, there are three Class options. The first is the Owner, who has created the file. However, this ownership can be changed in Linux. The Group setting would be the users who share the same file permissions. Other usually indicates the general public.
Read? Write? Execute?
Permissions can be set and changed as well. The three basic categories are Read, Write, and Execute. While the process is different, even Windows users will be familiar with the Read Only copy of a document, as well as with the choice to change to Edit mode, or with Linux, the Write mode. Execute is primarily used when a file needs to be run. The bottom line is the creator or owner of the file is deciding who can access the file and who can make changes to it. The Owner will usually have full permission – all three actions.
By The Numbers
With that in mind, why is a chmod followed by the numbers? Each file, each folder, has data that control the permissions. Starting with “000” the permissions could be changed to Read, which would make the control “100” in binary form. If this is changed to Write, the control would be “010.” To make a long story slightly shorter, think of the Read permission as 4 bit, Write as 2, and Execute as 1. In this system, a “0” means there is no permission, while at the opposite end of the spectrum, 7 means all permissions are given – read, write, and execute. The full scale is:
- 0 – No permissions
- 1 – Execute
- 2 – Write
- 3 – Write and Execute
- 4 – Read
- 5 – Read and Execute
- 6 – Read and Write
- 7 – Read, Write, Execute
So, the user comes up against 777. What is this trying to convey? In basic terms, again, the first digit is for the Owner – he or she can read, write, and execute the file. The second digit is assigned to the Group, as explained earlier. So the members of the Group can read, write, and execute the file. So can the general public, in the Other class. A combination of these numbers indicates exactly what can be done with the file and to the file, by whom.
A Traditional View
Consider this idea of control and compare it to keys that provide access to a building with several rooms. While this may seem simplistic, it does help to visualize what the chmod process does. The owner of a building may have a master key that opens every door, inside and out. This master key is the 7 in the first position of the three numbers. The second number, for a Group, is the key that opens doors inside and perhaps the main door to allow access to the building. If it is a “7” this means the members of the Group have the same access as the owner.
If the second number is any other numeral the Group members have the key to specific rooms inside and maybe the outside main door. Perhaps the number is 6, which means the Read and Write “rooms” are accessible to the Group. In the same vein, the last number, for Other, would probably be “0” for our building example, so that the general public would have no permission to access.
http://www.surfsafely.com/file-permissions-what-does-chmod-777-mean/ A nice picture of the process in graphic form.
If you are working on a Linux system, you can change file permissions by using the right-click on the file or folder and choosing “Properties.” Simply choose “Permission.” Then it is a matter of typing in the short form “chmod” and selecting the permissions you want with the three numerals. There are some special modes, only a few of which use numerals in the process of setting controls. These may not be important to most users and may never be used except by the owner or administrator.
A Second Way
The Owner of the file, who has all the permissions, may also indicate without numbers who can access the file and define exactly what each Class can do with it. For example, this is still a chmod but the Owner will state that the user can read, write, and execute by entering u=rwx, or state that the Group can read and execute the file by entering g=rx, and so on. The letters are chosen from the words, r for read, w for write, x for execute.
While this is somewhat detailed, the truth is there is much, much more to the subject. However, the serious user should be able to understand how file access and folder access are determined with just a little knowledge of chmod.