Move all user setting

I have a new server ( host A ) and a existing server ( host B ) , I will move all data from host A to host B , could suggest what is the best method to move all the user data including /etc/passwd . /etc/shadow , /etc/group , ~userid/.bash_profile , /home , how to make the user can use the same password after move the server ? thx

for /etc/passwd and /etc/shadow --- just grep out the user entries and append them into the appropriate files in the new servers so the uid, gid and passwords for the users stay the same ... a lot of places use the same group file entries so if this is the case with you, you can just copy over /etc/group to the new host also ...

for i in passwd shadow
do
    egrep -v "root|lp|smtp" /etc/$i > /tmp/$i
    scp /tmp/$i newhost:/tmp/$i
    ssh newhost "cat /tmp/$i >> /etc/$i; rm /tmp/$i"
    rm /tmp/$i
done
scp -p /etc/group newhost:/etc/group

for the home-related files and directories (i.e., .bash_profile, etc.), just copy them over ... if you have remote root ssh access on the remote server you can do the code below ... (change the correct paths to the user data directories on both local and remote hosts) ... for rsh access only, change the ssh to rsh ...

cd /home
tar cvfp - * | ssh newhost "cd /newhomedir; tar xvfp -"
tar cvfp - .[a-zA-Z0-9]* | ssh newhost "cd /homedir; tar xvfp -"

=========
or ... if you are not automounting home directories ...
=========

tar cvfp - /home | ssh newhost "cd /; tar xvfp -"

=========
or ... if you are automounting home directories ... (sample assumes it is automounted from /export/home) ...
=========

(cd /export; tar cvfp - home) | ssh newhost "cd /export; tar xvfp -"

there other transfer options you can use ... see "man dd", "man ufsdump", etc. depending on your OS platform ...

does linux has a command can do that ? thx

everything in Just Ices post will work, with the possible exception of egrep, which is sometimes not there and which you can just change to grep.

thx replies,

autcally I want to copy the user from unix to linux , I remember a command can do that , could advise ? thx