How to move or migrate user accounts from old Linux server to a new Linux server

https:/‮l.www/‬autturi.com
How to move or migrate user accounts from old Linux server to a new Linux server

To move or migrate user accounts from an old Linux server to a new Linux server, you can use the following steps:

  1. On the old server, create a list of user accounts to migrate. You can use the awk command to extract the username and home directory fields from the /etc/passwd file, like this:
awk -F: '{print $1 " " }' /etc/passwd

This will print a list of user accounts with the username and home directory separated by a space. You can save this list to a file for later reference.

  1. On the new server, create a new user account for each user in the list. You can use the useradd command to create a new user account, like this:
useradd -d /home/username -m username

This will create a new user account with the specified username and home directory, and create the home directory if it does not already exist.

  1. On the old server, create a tar archive of each user's home directory. You can use the tar command to create a tar archive, like this:
tar -czf username.tar.gz /home/username

This will create a tar archive named username.tar.gz of the /home/username directory.

  1. Transfer the tar archives to the new server using a secure file transfer method, such as scp or rsync.

  2. On the new server, extract the tar archives to the corresponding user's home directories. You can use the tar command to extract the tar archives, like this:

tar -xzf username.tar.gz -C /home/username

This will extract the contents of the username.tar.gz archive to the /home/username directory on the new server.

  1. On the new server, set the correct ownership and permissions for the files and directories in the user's home directories. You can use the chown and chmod commands to set the ownership and permissions, like this:
chown -R username: /home/username
chmod -R 700 /home/username

This will set the ownership of all files and directories in the /home/username directory to the username user and group, and set the permissions to 700 (read, write, and execute for the owner, and no access for others).

Created Time:2017-10-28 21:39:05  Author:lautturi