<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 30/07/2009, at 8:43 PM, Rimu Atkinson wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi all<br>
<br>
I copied several tens of gigabytes of files off a NTFS disk and every
single file has the most permissive permissions imaginable. Execute and
write for everyone (see <a class="moz-txt-link-freetext" href="http://rimu.geek.nz/Screenshot.png">http://rimu.geek.nz/Screenshot.png</a> )<br>
<br>
If I do chmod -x * then all the directories can't be opened any more,
which isn't cool. <br>
<br>
How can I set everything to something sane, like<br>
<br>
-rw-r--r-- 1 rimu rimu 357 2009-07-17 20:56 examples.desktop<br>
drwxr-xr-x 2 rimu rimu 4096 2009-07-18 09:02 Templates</font></div></blockquote><br></div><div>You want the amazing find command. If you want to do stuff to a bunch of files then find probably has the option you want.</div><div><br></div><div>find /path/to/base -type d -exec 'chmod' '755' '{}' ';'</div><div>find /path/to/base -type f -exec 'chmod' '600' '{}' ';'</div><div><br></div><div>This searches all subdirectories and files starting at /path/to/base/. -type specifies directory in the first case, then regular file in the second. Then we use the -exec command to call chmod. It's a bit strange as I single quote every argument so I don't forget to double escape. Also {} and ; need to be escaped from the main shell, otherwise bad things happen.</div><div><br></div><div>If you want to double check replace the -exec... bit with -print, it'll just print the files to console.</div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>--</div><div>Phillip Hutchings</div><div><a href="mailto:sitharus@sitharus.com">sitharus@sitharus.com</a></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br>
</body></html>