• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

Copy Users/groups

Hello I have 2 linux servers, csclpv012 and cdclpv014. I want to copy all the users from csclpv012 to csclpv014. Here is what I am thinking of
Copy /etc/passwd
Copy /etc/groups
Copy Home directories
Copy /etc/shadow
So by doing this will I be able to copy users and user credentials to another linux machine...

1 Solution
You will have to see if there basic services on both the machines are the same.  If basic system accounts are exactly the same the you need to issue the following command to do this

tar Ppcvf files.tar /etc/passwd /etc/groups /etc/shadow

Then you will transfer it by a method of your choice and then issue only one single command

tar Ppxvf files.tar

But if the system accounts and setup of the two computers different, you have to only copy the  related portions and then append those portions to the respective files.
I'd recommend against the copy unless the server to which this information is being copied was just built.

Any consideration setting up a centrally managed user/password i.e. OpenLDAP?

Care must be taken when combining already running servers as a change in UID/GID could adversely affect the functionality of some applications.
Since all file access are UID/GID based only the home directory of the account whose UID/GID changed will see the update not all the instances of directories/files where this account might be storing information/logs, etc..

I agree with Arnold.

If you want to centralize user accounts passwords, go for ldap or if you need a very quick and dirty in a totally secure lan, you may also go for NIS which is extremely easy to implement unlike LDAP.

Furthermore, you can centralize user accounts through NFS mounts.  This way, there will be only one centralized location and user accounts will be consistent.  If you have only two machines, you can export /home via NFS and mount it on the second computer
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

mnis2008Author Commented:
Yes the new server is just built and we want to have UID/GID for all the users same. I have like 100 accounts on the old server so I planned to copy the important files.

All this users have all there stuff set up in there home directories. I guess I need to rysnc the directories too...
Any thoughts against NFS mount?
Usually accounts are >1000 for users

awk -F: ' ($3>=1000) { print  } ' | ssh root@cdclpv014 'cat - \>\> /tmp/passwd'
Then you would merge the /tmp/passwd into /etc/passwd.
shift+G to get to the end, :r /tmp/passwd.

You would need to use rsync to sync the home directories.
You might want to consider looking into the Andrew File system (AFS)

If a single shared storage as an NFS mount as farzanj pointed out is not an option.
rsync can be used, but you have to be careful since usera can login into either system and add or remove files.
Here is a pretty good article that also describes the steps to take with different distros:

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Tackle projects and never again get stuck behind a technical roadblock.
Join Now