PDA

View Full Version : permissions for directories and files



mikji
10-23-2003, 08:27 PM
I have a directory that has both files and directories within it. The permissions for this directory, and all it's recursive contents, are set to 755. I want to recursively set all the permissions for all the files to 644 (-rw-r--r--) and all the directories to 744 (drwxr--r--). How can I do this without editing the files individually? If I do chmod -R 744 ./files/ then the directories will open fine, but the files will have the execute bit set. But if I do 'chmod -R 644 ./files/' all the files will be nonexecutable like i want, but the directories won't open (they need the executable bit). How can I recursively change permissions for files and directories separately? I have read all the chmod and chown docs I can find, and there is no mention of this problem. Any and all help is greatly appreciated.

Dave_Bechtel
10-24-2003, 09:42 PM
Try this: Set things to 644 first, then:


cd your-directory
chmod -cvR 644 .
find . -type d -exec chmod -cv 744 '{}' \;


--The goofy-looking syntax is to escape the "find" parameters so the shell doesn't try to deal with them.


I have a directory that has both files and directories within it. The permissions for this directory, and all it's recursive contents, are set to 755. I want to recursively set all the permissions for all the files to 644 (-rw-r--r--) and all the directories to 744 (drwxr--r--). How can I do this without editing the files individually? If I do chmod -R 744 ./files/ then the directories will open fine, but the files will have the execute bit set. But if I do 'chmod -R 644 ./files/' all the files will be nonexecutable like i want, but the directories won't open (they need the executable bit). How can I recursively change permissions for files and directories separately? I have read all the chmod and chown docs I can find, and there is no mention of this problem. Any and all help is greatly appreciated.

mikji
10-24-2003, 09:52 PM
That is exactly what I was looking for! Many thanks Dave.