Sorry but the above is hard for me to understand. Are you asking how
you can transfer users from /etc/passwd on one machine to another
machine? If that is your question then I would copy those users to
the new machine's /etc/passwd file. Copy the user account lines (user
accounts have uid's and gid's >=1000) from these files:
/etc/passwd
/etc/group
/etc/shadow
/etc/gshadow
Append the user account lines from those files onto the end of the new
machine's files. That is all that is needed.
These commands may be useful for extracting the user account lines
from these files.
awk -F: '$3>=1000' /etc/passwd
awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd
for i in $(awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd); do grep "^$i:" /etc/group; done
for i in $(awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd); do grep "^$i:" /etc/shadow; done
for i in $(awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd); do grep "^$i:" /etc/gshadow; done
Look this over, understand what they are doing, then append the
results onto the new files on the new system and the old users will
have been transferred to the new system.
awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd > /root/passwd.users
for i in $(awk -F: '$3>=1000 && $3<65534{print$1}' /etc/passwd); do grep "^$i:" /etc/group; done > /root/group.users
And so forth. Then copy those files to the new machine. Then append
those lines to the correct files on the new machine.
Hope that helps!
Bob