[clug] Syncronising UID/GIDs when migrating to LDAP

Adam Thomas adam.lloyd at gmail.com
Thu Sep 13 12:11:32 GMT 2007


On 13/09/2007, Sam Couter <sam at couter.id.au> wrote:
> Michael James <clug3 at james.st> wrote:
> > Years ago I migrated a batch by hand using:
> > root>  find -name <old-number> -exec chown <new-name> {} \;
>
> Eek! The -exec option to find will execute the program once for each
> file it finds. Much better to use xargs to execute with a whole bunch of
> files as arguments. Assuming GNU find and xargs:
>
> find <whatever> -print0 | xargs -0 chown <new-uid>
>
> This will be much faster.
This will however bomb out if the user owns enough files to hit the
command line length limit.

Perl's File::Find module might be of help here. Combine that with
Net::LDAP (i think) and the 'stat', 'getpwname' and 'chmod' built in
functions you might be able to automate the whole thing.


More information about the linux mailing list