Tuesday, June 26, 2018

How to copy all user on from one linux server to another linux server?

How to copy all user on from one linux server to another linux server?

If you just want to have the same users in the new system, you can get the list of users in your old server and add them in the new server with useradd within a loop as follows:
for i in $(cat users_list); do useradd $i; done
Note that this won't migrate the users data as you didn't mention it.
If you want to migrate the users with their old password and data, you can copy the lines concerning the users you want to migrate on files:
  • /etc/passwd
  • /etc/group
  • /etc/shadow
From old server to new server.
Now you may also copy the /home directory structure to your new sytem, so that the users can have access to their data.

No comments:

Post a Comment

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...