Move All Users to a New System

This section provides a tutorial example on how to move all users to a new Linux system.

How To Move All Users to a New System? If you are replacing an old Linux system with a new system, you can follow this tutorial to move all users and their files to the new system.

1. Do not add any regular users to the new system. This avoids user ID collision when moving old users to the new system. The following command should returns no output:

root# awk -F: '($3>=1000) && ($3!=65534)' /etc/passwd

Note that the third field in the "etc/password" file is user ID, which starts from 1000 for non-system users, User id 65534 is for "nobody", which is a dummy user.

2. Extract user information, including user names, user passwords, group names and group passwords on the old system:

herong$ sudo awk -F: '($3>=1000) && ($3!=65534)' /etc/passwd > passwd.old

herong$ awk -F: '{print $1}' passwd.old |tee - |sudo egrep -f - /etc/shadow > shadow.old

herong$ sudo awk -F: '($3>=1000) && ($3!=65534)' /etc/group > group.old

herong$ awk -F: '{print $1}' group.old | tee - |sudo egrep -f - /etc/gshadow > gshadow.old

3. Transfer and restore user information on the new system:

root# cat passwd.old >> /etc/passwd
root# cat shadow.old >> /etc/shadow
root# cat group.old >> /etc/group
root# cat gshadow.old >> /etc/gshadow

4. Verify one old user on the new system:

root# su herong
(Enter the old password)

bash-4.4$ exit
exit

5. Move user home directories:

# on old system:
herong$ sudo tar -zcvpf /tmp/home.tar.gz /home

\ transfer home.tar.gz to the new system
\ which may require a large amount of disk space

\ on new system:
root# cd /
root# tar -zxvf /tmp/home.tar.gz

6. Login the new system with one old user:

root# ssh herong@newhost
(Enter the old password)

herong$ pwd
/home/herong

6. Move user email files:

# on old system:
herong$ sudo tar -zcvpf /tmp/mail.tar.gz /var/spool/mail

\ transfer mail.tar.gz to the new system,
\ which may require a large amount of disk space

\ on new system:
root# cd /
root# tar -zxvf /tmp/mail.tar.gz

Now all users should be able to login to the new system and continue their work on the new system!

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Block Devices and Partitions

 LVM (Logical Volume Manager)

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Internet Networking Tools

 SSH Protocol and ssh/scp Commands

 Software Package Manager on CentOS - DNF and YUM

 vsftpd - Very Secure FTP Daemon

 LDAP (Lightweight Directory Access Protocol)

Administrative Tasks

 "systemctl status/start/stop/enable/disable" Commands

 "shutdown" and "halt/poweroff/reboot" Commands

 Move /home Directory to New Partition

Move All Users to a New System

 "last/lastb" - Review Login History

 References

 Full Version in PDF/EPUB