How to chmod 755 all directories but no file (recursively) ?
Inversely, how to chmod only files (recursively) but no directory ?
|
How to chmod 755 all directories but no file (recursively) ? Inversely, how to chmod only files (recursively) but no directory ?
| ||||
|
feedback
|
|
Directories, find /path/to/base/dir -type d -exec chmod 755 {} \;
Files: find /path/to/base/dir -type f -exec chmod 755 {} \;
If there are few objects to process, chmod 755 $(find /path/to/base/dir -type d) And like find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 find /path/to/base/dir -type f -print0 | xargs -0 chmod 755 | |||||
feedback
|
|
A common reason for this sort of thing is to set directories to 755 but files to 644. In this case there's a slightly quicker way than nik's
| |||||||||||||||
feedback
|
|
If you want to make sure the files are set to 644 and there are files in the path which have the execute flag, you will have to remove the execute flag first. +X doesn't remove the execute flag from files who already have it. Example:
Update: this appears to fail because the first change (ugo-x) makes the directory unexecutable, so all the files underneath it are not changed. | ||||
|
feedback
|
|
You could use the following bash script as an example. Be sure to give it executable permissions (755). Simply use ./autochmod.sh for the current directory, or ./autochmod.sh <dir> to specify a different one.
| |||
|
feedback
|