Disclaimer

This information HAS errors and is made available WITHOUT ANY WARRANTY OF ANY KIND and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is not permissible to be read by anyone who has ever met a lawyer or attorney. Use is confined to Engineers with more than 370 course hours of engineering.
If you see an error contact:
+1(785) 841 3089
inform@xtronics.com

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