SCIENTIFIC-LINUX-USERS Archives

August 2015

SCIENTIFIC-LINUX-USERS@LISTSERV.FNAL.GOV

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
David Sommerseth <[log in to unmask]>
Reply To:
Date:
Wed, 19 Aug 2015 16:19:43 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
On 19/08/15 15:32, Chris Schanzle wrote:
> On 08/19/2015 09:07 AM, David Sommerseth wrote:
>> On 19/08/15 14:51, Chris Schanzle wrote:
>> [...snip...]
>>> >I wouldn't imagine migrating to the new scheme would be*that* 
>>> difficult
>>> >once you nail down the user, old uid, new uid, change their passwd uid,
>>> >then run something like this on all your systems: find PATHS -user
>>> >$oldID -exec chown -h $newID {} +
>> I've done this a few times.  Basically my routine was:
>>
>> ---------------------------------------------------------------
>>   for d in /home /var /tmp;  # See note below
>>   do
>>      find $d -uid ${OLD_UID} -exec chown -ch ${NEW_UID} {} \;
>>      find $d -gid ${OLD_GID} -exec chgrp -ch ${NEW_GID} {} \;
>>   done;
> 
> That's fine, but there's no need for the loop -- just put all the paths
> right after "find".  And by using the + operator, you don't fork
> chown/chgrp for every file.

Cool, thanks a lot!  I didn't know about the + syntax.

The reason I used a for loop was actually more for readability when I
did the uid/gid split.  Performance wise, it might be better to gather
them all in a single 'find' call, especially when using +.

> If you're changing GID's too, separating out the GID search/reset is a
> good idea to ensure you get all the GID's (not just those matching a UID
> and using chown -h ${NEW_UID}:${NEW_GID}, which could result in
> unexpected GID changes.

Yeah, did that mistake on the first box I switched.  Luckily enough for
me, it was a small file system with not too many files.


-- 
kind regards,

David Sommerseth

ATOM RSS1 RSS2