chmod 775 to only the directories and chmod 664 to only the files?
Hello,
Is there a way to apply chmod 775 to only the directories and apply chmod 664 to only the files where there a mix of directories and files? I don't want to do chmod * 775 which will make all the files executable as well. |
If you are in the parent directory of the files and directories that you want to change then the following commands will do the job.
For directories only do this. Code:
find . -type d -exec chmod 775 {} \; Code:
find . -type f -exec chmod 664 {} \; The command for the directories will include the . and the .. directories where you issue the command. Make sure that you check the permissions on your current directory and its parent after you issue the commands. You can avoid this by providing a wildcard in the command to select the directories. The following command will not affect the . and the .. directories because it does not affect any files whose names begin with a dot. Code:
find . -type d -name \* -exec chmod 775 {} \; |
Awesome! Thanks!
|
If none of the files are set +x at the moment, you could also use the command 'chmod -R +X' (note upper case X). I think this adds execute permission to directories but not files. For whatever reason it doesn't seem to work the other way round, i.e. -X.
|
Quote:
|
Well, according to the manpage for chmod (e.g. here), the option +x (lowercase) adds execute permission to anything, whereas the option +X (uppercase) adds execute permission only if the target is a directory, and does nothing when the target is not a directory. Nothing magical about that. Should've checked that before I posted though, the reason that it does nothing that -X (uppercase) doesn't work is that it's not supposed to, the man page says it's ignored in all cases except +X.
|
Quote:
Quote:
|
All times are GMT -5. The time now is 08:24 PM. |