Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 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
1  
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

 
discard

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.