Migrate users groups


First run
$ pwck ; and
grpck
to make sure everything is correct
#!/bin/bash
# this assumes all people users (users and groups) are between 1000 and 9000
export UGIDLIMIT=1000 mkdir /root/move/ cd /root/move awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3<9000)' /etc/passwd > passwd.mig awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3<9000)' /etc/group > group.mig awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3<9000) {print $1}' /etc/passwd | tee tmp |egrep -f tmp /etc/shadow > shadow.mig cp /etc/gshadow gshadow.mig tar -zcvpf mail.tar.gz /var/spool/mail

Move the move directory to /root/move on the new machine. One probably should look over the files - you might want to remove cruft users and groups.

#!/bin/bash
rsync -au /etc/  /root/etc-bkup/
cd /root/move
cat passwd.mig >> /etc/passwd
cat group.mig >> /etc/group
cat shadow.mig >> /etc/shadow
/bin/cp gshadow.mig /etc/gshadow
cd /
tar -zxvf /root/move/mail.tar.gz
You will have to create home directories if needed. Try
 $ mkhomedir_helper <username>
echo "you likely want to reboot right now"

Top Page wiki Index

Disclaimer

This information may have errors; It is not permissible to be read by anyone who has ever met a lawyer.
Use is confined to Engineers with more than 370 course hours of electronic engineering for theoretical studies.
ph +1(785) 841-3089

Email inform@xtronics.com

(C) Copyright 1994-2017, Transtronics, Inc. All rights reserved
TranstronicsĀ® is a registered trademark of Transtronics, Inc.
All trademarks are the property of their respective owners.