[svlug] How do I recursively chmod 0664 files but not directories?

William R Ward bill at wards.net
Sat Jul 16 14:31:26 PDT 2005


Daevid Vincent writes:
>I accidentally typed "chmod -R 0775 /mydir", so now all directories AND
>files are +x
>
>What magical bash incantation can I type to recursively go through and make
>all files 0664 but make directories 0775?

To undo the problem:
find . -type f -print | xargs chmod 664
Note that any executable files will no longer be; if there is a "bin"
directory you may need to change those back to 755.

A better way to change just the directories instead of what you did:
find . -type d -print | xargs chmod 775

Or assuming the files were previously 755 (directories & executables)
and 644 (plain files), then to add group writable without affecting
anything else:
chmod -R g+w .

--Bill.

-- 
William R Ward               bill at wards.net             http://bill.wards.net
-----------------------------------------------------------------------------
   Help save the San Jose Earthquakes - http://www.soccersiliconvalley.com/




More information about the svlug mailing list