Unix Permissions Basics

First thing to know if you wish to be a Web developer, Software Developer or any kind of developer dealing with Web Servers like CentOS or Ubuntu or Solaris based reporting systems. Anyways you get the point.

The machine closer to your sphere of programming probably is Dev Box. So, maybe if you are teaching yourself these new perms concept , you can do proof-of-concept on dev Box.

I will just do a quick and simple explanation:

There are three kind of users for any directory, file, device or anything that uses unix OS resources: those who own it, those who are sharing it and others.

those who own it             –> owner

those who are sharing it  –> group

others                                –> others

I will only discuss numeric mode, but i will love if you can send me the letter mode tutorial (link or text).

A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1.  Any omitted digits  are  assumed  to  beleading  zeros.

LEVEL 1:  read, write and execute permissions

read       = 4

write      = 2

execute  =1

so , read + write + execute = 4 + 2 + 1 = 7

This addition is same for all three type of users .

Ex: 775 => owner = 7, group=7 and others = 5

USAGE Examples :

a) Only File/Dir :                                 chmod  775 my_dir

b)  Recursively apply permissions:     chmod  -R 775 my_dir

 LEVEL 2: user ID , group ID and Sticky attributes

userID:  when the file will be executed by a user, the process will have the same rights as the owner of the file being executed.

GroupID: Same as above, but inherits rights of the group of the owner of the file. For directories it also may mean that when a new file is created in the directory it will inherit the group of the directory (and not of the user who created the file).

Sticky Bit:use is system dependant and it is mostly used to suppress deletion of the files that belong to other users in the folder where you have “write” access to.

userID(s)       = 4

GroupID(s)   = 2

Sticky Bit(t)  = 1

so, userId + GroupID + Sticky Bit = 7

This is the first of the four permission octal values.

Ex: 2775 => groupID = 2 , owner = 7, group=7 and others = 5

USAGE Examples :

a) Only File/Dir :                                 chmod 2775 my_dir

b)  Recursively apply permissions:     chmod  -R 2775 my_dir


Hope you find it useful.





1) http://www.zzee.com/solutions/unix-permissions.shtml