Copy /etc/passwd, /etc/group to another server (62 Views)
Reply
Frequent Advisor
d_bachelor01
Posts: 67
Registered: ‎11-21-2007
Message 1 of 10 (62 Views)
Accepted Solution

Copy /etc/passwd, /etc/group to another server

Hi Guys,

I need to copy the users from one server to another and create their home directories as well. Any specific instructions on how to do this? Can I just copy the /etc/passwd and /etc/group? How about the directories? Do I have to create them manually?

Thanks in advance!

-jef
Esteemed Contributor
Ramesh S
Posts: 233
Registered: ‎01-08-2008
Message 2 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

Honored Contributor
Kapil Jha
Posts: 1,478
Registered: ‎01-23-2006
Message 3 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

Yes you can just copy passwd and group file.
You will have to make directories manually or copy the direcories to new system.
BR,
Kapil
I am in this small bowl, I wane see the real world......
Frequent Advisor
d_bachelor01
Posts: 67
Registered: ‎11-21-2007
Message 4 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

any faster way to create those directories? thanks!
Honored Contributor
Kapil Jha
Posts: 1,478
Registered: ‎01-23-2006
Message 5 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

make a tar or backup of /usr/users directory or wherever your home directories are and extract on target system.

Use -p to preserve permissions.

BR,
kapil
I am in this small bowl, I wane see the real world......
Frequent Advisor
d_bachelor01
Posts: 67
Registered: ‎11-21-2007
Message 6 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

Hi Kapil

I tried to make a tar backup of my home directory. My current set up is that user directories are located on /home/user/user1....
/home/user/user2....
/home/user/user3....
.....

#tar cvf /tmp/home.tar /home/user/

however, my tar archive contains only the contents of each users home directories. I cannot see the subdirectories of the /home/user. Also, how can I preserve the permission of each folder and its subdirectories?

Thanks,
-jef
Honored Contributor
Peter Nikitka
Posts: 1,575
Registered: ‎02-10-2003
Message 7 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

Hi,

when doing your backup
- I recommend NOT to use absolute pathnames.
- Create your tarfile at a place containing enough freespace (/tmp may be not big enough)
Use
cd /home
tar cvf /somewhere/backuser.tar user

You will see the progress of the backuped files on stdout.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Frequent Advisor
d_bachelor01
Posts: 67
Registered: ‎11-21-2007
Message 8 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

Hi Peter,

I dont have enough space on my /home/user directory. Anyway, I have more than 100 users.. I tried making an archive using tar but it seems that only the contents of the users home directories are copied. It is not divided according to "each" users own home directory. Any suggestions on how to make it done the fastest way? Also, I need to preserve the permissions including those in the sub-directories. It would really take some time if I would archive each home directories one by one.

Thanks!
-jef
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 9 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

>My current set up is that user directories are located on /home/user/user1....

(This seems like an extra level of indirection.)

>#tar cvf /tmp/home.tar /home/user/
>my tar archive contains only the contents of each user's home directories. I cannot see the subdirectories of the /home/user.

You have dumped the subdirectories of the /home/user, what do you think is missing?
I suppose if each home directory is automounted, tar may not see them all?
Yes, this happens to me. You'll need:
#tar cvf /tmp/home.tar /home/user/*

Of course if this is automounted, then there is no need to move them because they aren't there on that machine.

>how can I preserve the permission of each folder and its subdirectories?

As Kapil said, you can use -p. But that is the default for root, when you extract.

>Peter: I recommend NOT to use absolute pathnames.

You can always use pax(1) to rename it.

> cd /home; tar cvf /somewhere/backuser.tar user

You can combine these into:
tar cvf /somewhere/backuser.tar -C /home user

>I don't have enough space on my /home/user directory.

That's why Peter said: /somewhere

>but it seems that only the contents of the users home directories are copied. It is not divided according to "each" users own home directory.

This is contradictory. /home/user contains ALL user's home directories. tar should get all of them if you start at /home/user.
Unless some are symlinks??

You need to give an example of a file that isn't backed up. And see if that shows up with "ll /home/user".

>Any suggestions on how to make it done the fastest way?

Mount them over NFS?

>I need to preserve the permissions including those in the sub-directories.

Automatic for root.

>It would really take some time if I would archive each home directories one by one.

You need to explain to us why the command you or what Peter gave isn't working.
Frequent Advisor
d_bachelor01
Posts: 67
Registered: ‎11-21-2007
Message 10 of 10 (62 Views)

Re: Copy /etc/passwd, /etc/group to another server

It's working now guys! Actually my command really works. The problem is with the transferring of the tar file to the other server. When I checked the size, its different from the original one. Thanks for all your help!!!

-jef
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.