Page 1 of 1

Moving users and groups

Posted: 2019/03/04 00:36:13
by ben_tvpp
Hi, I'me doing a Centos 6 to 7 upgrade. I am keeping the home partition from the CentOS install as it has a lot of data and I wish to keep the group and user permissions (including uid/gid/user/group)..

I know I can user -gid and -uid options for adduer but according to docs

Code: Select all

Use the -g (--gid) option to create a user with a specific initial login group. You can specify either the group name or the GID number. The group name or GID must already exist.
The reason I need to do this is that the data in /home is actually a backup of a production server (which has actually died).

Is there a way of doing this?


Re: Moving users and groups

Posted: 2019/03/04 01:34:07
by billwest
I actually did something similar quite a while (a few years) ago.
I copied and pasted relevant parts of /etc/passwd, /etc/shadow, /etc/group from one machine to another, and it seemed to work.
If you use samba, it may require a bit more work.
No guarantees given.

Re: Moving users and groups

Posted: 2019/03/04 11:06:52
by tunk
I have done the same for two CentOS 7 systems (with the addition of /etc/gshadow).
If your old system uses SHA256 password hashes, you may want to force your users to
set new passwords to get SHA512 (not sure if this will work).

Edit: before doing anything with those files, make a copy just in case anything goes wrong.

Re: Moving users and groups

Posted: 2019/03/05 00:12:53
by ben_tvpp
Thanks, that seems to work.