I'd like to recursively chmod a directory so that:
- Files are 0664
- Directories are 0775
How to do it better, shorter, fancier? :) Maybe, use umask somehow?
All find solutions are too long: I always end with Copy-Paste :)
|
I'd like to recursively chmod a directory so that:
How to do it better, shorter, fancier? :) Maybe, use umask somehow? All |
||||
|
Depending on your version of chmod, you may be able to do this:
Note the capital X. This sets the executable bit on directories and files that already have any of the execute bit already set. Note that you can only use capital X with '+', not '=' or '-'. |
|||||
|
|
|
Better, shorter, fancier than what ?
|
|||||||||||
|
|
Adding a oneliner to the mix
|
|||
|
|
Test it before use it in real environment |
||||
|
|
|
I am using this for anything copied from FAT filesystems:
If it does not work, for example on Mac OS X, try the GNU version of the command
|
|||
|
|
|
Without knowing more about why you're trying to do this, the most common reasons people tend to use are either:
Or, combine the two:
Alternately, if you want files and directories to the correct permissions by default, modify the creating process's Basically, it's a rare day that it's correct to use numeric modes with |
|||
|
|
find, specifying either directory or file flags, with an -exec tochmod... – ewwhite May 4 '12 at 18:01find, it begs the question: why not fix the permissions viaumask(or some program-specific option) so that they're correct in the first place? – BMDan May 4 '12 at 21:30