Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory with millions of files and sub directories and I need to change the permissions on the entire directory and its files and its take many hours to do this. I was wondering if there is a quicker way of doing this than the normal chmod -R command?

share|improve this question
up vote 6 down vote accepted

Your chmod -R is quite optimal. There have to be one chmod() syscall per file and filesystem has to update it's metadata on block device.

Disable barriers (mount option on XFS, Ext4 etc.) on this FS if enabled but remember to enable them later.

I hope it's one time action and not recurring problem? If easy management of file permissions is more important than performance and simplicity you could try to write some overlay FUSE filesystem mangling permissions and uid/gid on-the-fly.

share|improve this answer

You'd want to write a script and execute from the root directory. I think a basic one would go something like this;

chmod 777 ./stuff/stuff
chmod 777 ./stuff/stuff 

chmod 666 ./stuff/stuff
chmod 666 ./stuff/stuff

Etc, etc, etc... There might be a better script or a better way. I'm not very good at scripting.

share|improve this answer
I'm basically doing chmod -R 777 /dir/ – Eric Fouarge Feb 10 '12 at 16:42
writing a script to chmod files one at a time is guaranteed to be slower – stew Feb 10 '12 at 21:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.