Simple chmod
Written by Sam Moffatt   
Wednesday, 17 October 2007 11:09

This article covers a more friendly way of using the chmod command instead of trying to memorize ugly mode strings!

The chmod command is used to change the basic rights the user, group or world/other has over a file or folder. What is less known is that you don't always have to resort to using octal mode strings (e.g. 777, 644, etc) to set anything more complex:


$ chmod -R u+rwX,g+rwX,o+rX *

What this does is set:

  • user permissions: u+rwX (read, write and directory traversal or execute for files where something else has set the execute bit)
  • group permissions: g+rwX (as above)
  • other permissions: o+rX (read and directory traversal) 

I've used them put together here and comma seperated however you can use them individually, so to just set other (not user or group):

chmod o+rw filename

Please note if not exactly specified it will apply to all (user, group and other), e.g.:

chmod +rw filename

Gives user, group and other read and write access to the file. -R is used for recursively setting permissions over directories and their contents. In this example I've also used + to add the values to files that might not have it. We can use - to remove that permission and = to ensure that it all equals those permissions.

Last Updated on Tuesday, 11 December 2007 18:10