Chmod (File Permissions) in *nix System Explained

File Per­mis­sions plays impor­tant role in *nix OS, if you are a web­mas­ter then you must have faced some sit­u­a­tions when due to file per­mis­sions your web appli­ca­tions wont behave as per except­ed or some time it shows 500 error or some­time it makes your script not able to read/write a file. You must have solved these sort of prob­lems by apply­ing chmod 777 or chmod 750 com­mands , and your script starts work­ing. But for the curi­ous users who wants to know that what hap­pens in behind the scene this arti­cle will explain all those things.

File Per­mis­sions are the roles which defines that who (user,group,world) can do what (read, write, exe­cute ) oper­a­tions on that file or direc­to­ry.

There are 3 enti­ty which needs to deal with file, these are -

  1. User (root,vivex,www-data,apache etc)
  2. Group (each user is asso­ci­at­ed with a group)
  3. Oth­ers (all oth­er world)

And there is 3 per­mis­sions

  1. Read (weight 4)
  2. Write (weight 2)
  3. Exe­cute (weight 1)

these weight makes the dig­its 755 and all , how?

Sup­pose if we want that user can read a file and group and oth­ers with no per­mis­sion then for user (read = 4) so just chmod file to 400 -

User Group Oth­er

4 0 0

for read and write – 4+2 = 6 , for read+write+execute – 4+2+1 = 7

Same apply for direc­to­ries if a direc­to­ry have only write per­mis­sion then it makes no sense since you cant read the con­tent, you can even exe­cute ls in that direc­to­ry, Nei­ther you can enter into it. Only exe­cut­ing per­mis­sion to direc­to­ry also make no sense, you can do only cd and enter into the direc­to­ry but you cant read nor write files in that direc­to­ry, so for user you have to give all three per­mis­sion to that direc­to­ry.


Web Developer & Server Admin, Skilled in Java , PHP , LAMP, Tomcat, Mongo DB & SQL. Available for freelancing project or Open Source Contribution, Feel free to contact me at .

You may also like...