No, unfortunately they are not the same. Even though I installed Ubuntu 10.04 server on both machines following (almost) the same procedure, the UIDs of system users are different. I probably didn't install all the packages in the same order. For example:
mysql (UID): 106 -> 104
clamav (UID): 110 -> 106 (so mysql data on Comp1 is owned by clamav on Comp2)
I want to match UIDs and GIDs on both machines. To do that I first need to copy them (passwd, group, shadow) from Comp1 to Comp2. Afterwards I need to change ownerships of the files on Comp2 to match the changes in passwd, group and shadow files.I don't see why your approach includes both chown and juggling passwd and shadow files.
That way I will also be able to move the HDD in the future without any needed adjustments because the UIDs and GIDs will be the same on both machines (unless I add new users).
Very good point. Hmm... I could use a temporary random UID and use it as an intermediary:The one thing you need to look out for is this:
say you chown from 1300 to 1400
say you also need to change files from 1400 to something else
how do you distinguish between 'real 1400' and '1400 that were 1300 previously' ?
1300 -> 1500(temporary UID)
1400 -> 1300
1500 -> 1300
I just tried it and the temporary UID doesn't even have to belong to any user in passwd file.