[CentOS] Changing UID numbers

Thu Feb 14 17:04:11 UTC 2019
Bill Gee <bgee at campercaver.net>

Hello everyone -

I have a question regarding UID and GID numbers.  First, a bit of background:

Yesterday I suffered a complete power failure.  My UPS batteries ran everything for an hour, but that was not long enough.  My CentOS6 server shut itself down, just like it should.  When the power came back up, the perfectly running server was no longer working.  The boot hard drive was complete toast.  ARGH!

OK, I have backups and spare hard drives.  CentOS6 is getting a bit long in the tooth.  I have to reformat and reinstall CentOS before restoring backups anyway, so I decided now is the time to move to CentOS7.  I chose to rip the bandage!

The CentOS6 installation was quite old.  Back in those days the default UID for new users was 500.  That's how I set up my user account on the machine.  My main workstation is Fedora 29, but it started life MANY cycles ago and also has my UID=500.  That all works nicely with the nfs share coming off the server.

On newer builds I have wrestled with having my UID=1000, as is the new standard.  File permissions on the nfs share were never quite right.  It was not irritating enough to make me desperate, but it was annoying.  I got around it with a lot of 777 and 666 permissions settings.  I looked at rpc-idmapd but was never able to make it work.

Now with CentOS7 my server user account is UID=1000.  The nfs share is on a separate drive (not the one that failed), and all of the files on it are still owned by UID=500.  It works from my main workstation, but is really unclean.

So now the questions:

What will it take to change all the files to the new UID?  What will it take to change my main workstation to the new UID **without** having to create a new user account?

I think I can do this in two steps.  

0) backup, backup, backup!
1) On the server - use "find" to find all files owned by UID=500.  Chown them to UID=1000.  Repeat for gid=500.
2) Tricky - On the workstation, boot to non-gui.  Login as root.  Repeat the same two "find" commands as on the server.  Edit the /etc/passwd and /etc/group files to show the new UID and GID numbers.

What does this do to the shadow files?  Are there other places I need to look for the UID and GID numbers?

Thanks!

-- 
Bill Gee