uid & gid problem restoring ubuntu made backup to new squeeze install

Nico Kadel-Garcia's picture

Forums: 

On Sat, May 14, 2011 at 1:17 AM, Brian Ryans wrote:
> Quoting Juan R. de Silva on 2011-04-21 16:36:
>> I preserved the user names for both of users in a new squeeze
>> installation but UID and GID are different. So, by simply using 'cp -
>> a' (or rsync) I would run into problem of their mismatch.
>>
>> Is there a simple and quick way to resolve it or I'll have to go trough
>> this mess manually one step at a time?
>
> See find(1) and chown(1). If you prefer info documents, the {core,find}utils
> files will be of much use.

Be *very* careful doing this, as well. It's often easier to designate
a much higher uid/gid space, such as 1000-11000, as a temporary
holding space to change the uid's to one at a time, then switch the
files owned by that uid to the target account. This helps avoid
problems with temporary files created by both the old and new uid's,
and the possibility of accidentally overlapping uid's.

For example, my uid on the old machine is 500. My uid on the new uid
is 520. My friend on the new machine has uid 500. I now alter all
backup files, mail files, /var/spool/crontab files, and relevant /tmp/
files to be uid 500. But wait! I'm overlapping my friend! Chaos
ensues.