When you are new to Linux or don't use Linux on a daily basis, finding out how file permissions work can be challenging. Here is an as short as possible guide, which can be applied on UNIX, Linux, Mac OS X, FreeBSD, OpenBSD, and other UNIX-like operating systems. We'll call those systems *nix in this guide.
*nix splits permissions in thee groups for files and directories:
Besides ownership of files and directories, certain permissions can be given as well:
These permissions are set using chmod. (Change Mode.) Ownership of file is altered with chown. (Change Owner)
Chmod wants to know what permissions you give to a file or directory. This value is built up on four fields.
The zeroth field represents the special bits. (Set User id, Set Group id and Stikcy bit, see below.) Most users will not set this bit, which makes it "0" by default, which means: "No special permissions set."
The first field represents the permissions you give to the Owner.
The second field represents the permissions you give to the Group.
The third fiels represents the permissions you give to the World.
Chmod uses numerical arguments to set permissions, to illustrate it a bit: chmod 750 myscript.sh would change permissions for the file myscript.sh.
Read permissions equals a value of 4.
Write permissios equals a value of 2.
Execute permissions equals a value of 1.
Add the numbers representing the permissions you'd like to give to a Owner, Group or World.
So here is a list of common permissions:
Some "weird" permissions, mostly because they are broken or very rare:
There are some special permissions you can give, these permissions go into the zeroth field. You'd use chmod like this to set no special permissions: chmod 0750 myscript.sh.
So 4750 would mean the file may be executed by the owner and the group, and will be executed as the owner.
Imagine a script would have 4775 permissions and would be owned by root:users; a user could edit the script, and the world could execute it with roots permission!
Just to remind you once more; Set Group or User id bits are dangerous, know what you are doing when using them!
| About | Consultancy | Articles | Contact |
|
|
|
|
|
| References | Red Hat Certified Architect | By Robert de Bock | Robert de Bock |
| Curriculum Vitae | By Fred Clausen | +31 6 14 39 58 72 | |
| By Nelson Manning | [email protected] |