CHMOD (change mode) is a Unix command that tells the server how much access it can grant to a file (permissions). There are three types of user: owner (you, includes the server), group (a specific group of people) and public (everybody else). Each type of user can have three levels of access: read (can view a file), write (can write and delete a file) and execute (can run a file/program).
You can set the individual permissions for each type of user. For example, you (owner) might want to read, write and execute "database.cgi", but you do not want strangers (public) to be able to update (or destroy) the database! So, we use chmod to set the permissions of the file so that anybody can read and execute (run) the database (assuming it's not secret), but only you can write to the database (i.e., update its contents).
The references (or classes) are used to distinguish the users to whom the permissions apply. They are represented by one or more of the following letters:
When setting chmod values, you sometimes see a string of letters like
The string of letters correspond to the names of the file permissions (read, write, execute), whereas, each digit in the number sequence represents the sum of permissions for each type of user. That is because each permission has a numerical value: read = 4, write = 2 and execute = 1.
Each of these digits is the sum of its component bits (see also Binary numeral system). As a result, specific bits add to the sum as it is represented by a numeral:
(4=r)+(1=x) == (5=r-x)
(4=r)+(2=w) == (6=rw-)
(4=r)+(2=w)+(1=x) == (7=rwx)
Here is a summary showing which octal digits affect permissions for user, group, and other:
You can set the individual permissions for each type of user. For example, you (owner) might want to read, write and execute "database.cgi", but you do not want strangers (public) to be able to update (or destroy) the database! So, we use chmod to set the permissions of the file so that anybody can read and execute (run) the database (assuming it's not secret), but only you can write to the database (i.e., update its contents).
The references (or classes) are used to distinguish the users to whom the permissions apply. They are represented by one or more of the following letters:
When setting chmod values, you sometimes see a string of letters like
rwxr-xr-x
or a three digit number like 755. Both of these examples mean the same thing: the owner can read, write and execute a file, the group can read and execute a file, and the public can read and execute a file.The string of letters correspond to the names of the file permissions (read, write, execute), whereas, each digit in the number sequence represents the sum of permissions for each type of user. That is because each permission has a numerical value: read = 4, write = 2 and execute = 1.
Reference | Class | Description |
---|---|---|
u | user | the owner of the file |
g | group | users who are members of the file's group |
o | others | users who are not the owner of the file or members of the group |
a | all | all three of the above, is the same as ugo |
- The read bit adds 4 to its total,
- The write bit adds 2 to its total, and
- The execute bit adds 1 to its total.
- 1 --x execute
- 2 -w- write
- 3 -wx write and execute
- 4 r-- read
- 5 r-x read and execute
- 6 rw- read and write
- 7 rwx read, write and execute
(4=r)+(1=x) == (5=r-x)
(4=r)+(2=w) == (6=rw-)
(4=r)+(2=w)+(1=x) == (7=rwx)
Here is a summary showing which octal digits affect permissions for user, group, and other:
- UGO = User, Group, Other
- 777 = "-rwxrwxrwx" = rwx for all
- 754 = "-rwxr-xr--" = rwx for user, r-x for group, r-- for other
- 124 = "---x-w-r--" = x for user, w for group, r for other
No comments:
Post a Comment
Confused? Feel free to ask
Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.
Note:
Please do not spam Spam comments will be deleted immediately upon my review.