[wellylug] permissions munted
Phillip Hutchings
sitharus at sitharus.com
Thu Jul 30 20:56:11 NZST 2009
On 30/07/2009, at 8:43 PM, Rimu Atkinson wrote:
> Hi all
>
> 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 http://rimu.geek.nz/
> Screenshot.png )
>
> If I do chmod -x * then all the directories can't be opened any
> more, which isn't cool.
>
> How can I set everything to something sane, like
>
> -rw-r--r-- 1 rimu rimu 357 2009-07-17 20:56 examples.desktop
> drwxr-xr-x 2 rimu rimu 4096 2009-07-18 09:02 Templates
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.
find /path/to/base -type d -exec 'chmod' '755' '{}' ';'
find /path/to/base -type f -exec 'chmod' '600' '{}' ';'
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.
If you want to double check replace the -exec... bit with -print,
it'll just print the files to console.
--
Phillip Hutchings
sitharus at sitharus.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20090730/72ece8c4/attachment.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2302 bytes
Desc: not available
Url : http://lists.wellylug.org.nz/pipermail/wellylug/attachments/20090730/72ece8c4/attachment.bin
More information about the wellylug
mailing list