22
4/20/13 Move or migrate user accounts from old Linux server to a new Linux server www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 1/22 Main menu BASH Shell Linux CentOS Debian / Ubuntu Ubuntu Linux Suse RedHat and Friends Slackware Linux UNIX AIX Mac os x FreeBSD FreeBSD Jails (VPS) Openbsd Solaris Troubleshooting Nginx Networking MySQL See all tutorial topics Blog About Contact us Forum RSS/FEED Linux FAQ / Howtos Move or migrate user accounts from old Linux server to a new Linux server by nixCraft on December 13, 2006 · 83 comments · last updated at August 16, 2007 Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation. A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x. Following files/dirs are required for traditional Linux user management: * /etc/passwd - contains various pieces of information for each user account * /etc/shadow - contains the encrypted password information for user's accounts and optional the password aging information.

Move or Migrate User Accounts From Old Linux Server to a New Linux Server

  • Upload
    -

  • View
    49

  • Download
    6

Embed Size (px)

Citation preview

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 1/22

    Main menu

    BASH Shell

    Linux

    CentOS

    Debian / Ubuntu

    Ubuntu Linux

    Suse

    RedHat and Friends

    Slackware LinuxUNIX

    AIX

    Mac os x

    FreeBSD

    FreeBSD Jails (VPS)

    Openbsd

    Solaris

    Troubleshooting

    NginxNetworking

    MySQL

    See all tutorial topics

    BlogAbout

    Contact us

    Forum

    RSS/FEED

    Linux FAQ / Howtos

    Move or migrate user accounts from old Linuxserver to a new Linux server

    by nixCraft on December 13, 2006 83 comments last updated at August 16, 2007

    Q. How do I Move or migrate user accounts to from old Linux server a new Cent OSLinux server including mails? This new system a fresh installation.

    A. You can migrate users from old Linux server to new Linux sever with standard

    commands such as tar, awk, scp and others. This is also useful if you are using old

    Linux distribution such as Redhat 9 or Debian 2.x.

    Following files/dirs are required for traditional Linux user management:

    * /etc/passwd - contains various pieces of information for each user account

    * /etc/shadow - contains the encrypted password information for user's accounts and optional the password

    aging information.

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 2/22

    * /etc/group - defines the groups to which users belong

    * /etc/gshadow - group shadow file (contains the encrypted password for group)

    * /var/spool/mail - Generally user emails are stored here.

    * /home - All Users data is stored here.

    You need to backup all of the above files and directories from old server to new Linux server.

    Commands to type on old Linux system

    First create a tar ball of old uses (old Linux system). Create a directory:

    # mkdir /root/move/

    Setup UID filter limit:

    # export UGIDLIMIT=500

    Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only

    copy user accounts)# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd >

    /root/move/passwd.mig

    Copy /etc/group file:

    # awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group >

    /root/move/group.mig

    Copy /etc/shadow file:# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd

    | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig

    Copy /etc/gshadow (rarely used):# cp /etc/gshadow /root/move/gshadow.mig

    Make a backup of /home and /var/spool/mail dirs:# tar -zcvpf /root/move/home.tar.gz /home

    # tar -zcvpf /root/move/mail.tar.gz /var/spool/mail

    Where,

    Users that are added to the Linux system always start with UID and GID values of as specified byLinux distribution or set by admin. Limits according to different Linux distro:

    RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).

    You should never ever create any new system user accounts on the newly installed Cent OS Linux. Soabove awk command filter out UID according to Linux distro.

    export UGIDLIMIT=500 - setup UID start limit for normal user account. Set this value as per yourLinux distro.awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd >

    /root/move/passwd.mig - You need to pass UGIDLIMIT variable to awk using -v option (it assignsvalue of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field

    separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generatesnew file /root/move/passwd.mig. Same logic is applies to rest of awk command.

    tar -zcvpf /root/move/home.tar.gz /home - Make a backup of users /home dirtar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 3/22

    Use scp or usb pen or tape to copy /root/move to a new Linux system.# scp -r /root/move/* [email protected]:/path/to/location

    Commands to type on new Linux system

    First, make a backup of current users and passwords:

    # mkdir /root/newsusers.bak

    # cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    Now restore passwd and other files in /etc/

    # cd /path/to/location

    # cat passwd.mig >> /etc/passwd

    # cat group.mig >> /etc/group

    # cat shadow.mig >> /etc/shadow

    # /bin/cp gshadow.mig /etc/gshadow

    Please note that you must use >> (append) and not > (create) shell redirection.

    Now copy and extract home.tar.gz to new server /home

    # cd /

    # tar -zxvf /path/to/location/home.tar.gz

    Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail

    # cd /

    # tar -zxvf /path/to/location/mail.tar.gz

    Now reboot system; when the Linux comes back, your user accounts will work as they did before on old

    system:# reboot

    Please note that if you are new to Linux perform above commands in a sandbox environment. Abovetechnique can be used to UNIX to UNIX OR UNIX to Linux account migration. You need to make couple

    of changes but overall the concept remains the same.

    Further readings

    Read man pages of awk, passwd(5), shadow(5), group(5), tar command

    Updated for accuracy.

    Tweet13

    Like 11

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 4/22

    You should follow me on twitter here or grab rss feed to keep track of new changes.

    Featured Articles:

    30 Handy Bash Shell Aliases For Linux / Unix / Mac OS XTop 30 Nmap Command Examples For Sys/Network Admins

    25 PHP Security Best Practices For Sys Admins

    20 Linux System Monitoring Tools Every SysAdmin Should Know20 Linux Server Hardening Security Tips

    Linux: 20 Iptables Examples For New SysAdmins

    Top 20 OpenSSH Server Best Security Practices

    Top 20 Nginx WebServer Best Security Practices20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors

    15 Greatest Open Source Terminal Applications Of 2012

    My 10 UNIX Command Line Mistakes

    Top 10 Open Source Web-Based Project Management SoftwareTop 5 Email Client For Linux, Mac OS X, and Windows Users

    The Novice Guide To Buying A Linux Laptop

    { 82 comments read them below or add one }

    1 podee December 21, 2006 at 4:00 am

    Hi

    I followed your instuction on CentOS 4.4. When I reboot I lost my root user and gdm dint start.

    I could login from all user but not root.Can you help to give me some advices please?

    Pordee

    Reply

    2 nixcraft December 21, 2006 at 7:59 am

    You made mistake somewhere. But dont worry you can login into single user mode (rescue mode)

    and reset root account password.

    http://www.cyberciti.biz/faq/linux-reset-forgotten-root-password/

    Reply

    3 ssdon January 2, 2007 at 10:25 pm

    Great! The following line is probably a typo as Im assuming you mean to back this up with a copy,

    otherwise you nuke the password files (probably what happened to nixcraft)

    # mv /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    # cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 5/22

    Reply

    4 nixcraft January 3, 2007 at 1:50 am

    ssdon,

    Typo has been fixed.

    Appreciate your feedback.

    Reply

    5 Tom January 3, 2007 at 2:17 am

    There is an error in the article. In the step where you back up the passwd, group, shadow, and

    gshadow files from the new system to the newuser.bak directory, use the cp command, not mv.

    In other words, the article should read:

    Commands to type on new Linux system

    First, make a backup of current users and passwords:# mkdir /root/newsusers.bak

    # cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    Reply

    6 Bud January 15, 2007 at 5:50 pm

    Your instructions worked perfectly when migrating accounts from Redhat 4ES to another Redhat 4ES.

    I added a couple of steps to move all the aliases and aliase folders to the new server. Thanks

    Reply

    7 Oduor Sam January 21, 2007 at 8:09 pm

    Thanks,I am looking for a payrise after rescuing a dying server. It has worked for me perfectly.

    Reply

    8 Rick January 31, 2007 at 3:34 am

    It may sound complicated, however, I am much more happy to do this with Linux than with

    Mickey$oft O/Ss, in fact, I am much more happy to do ANYTHING with Linux over Windoze!

    Reply

    9 _ranger_ January 31, 2007 at 12:38 pm

    If you had used LDAP for user accounts, then you wouldnt have needed to migrate user accounts .

    Also, you could skip the whole tar aspect by just using rsync, e.g. rsync -e ssh -avtP /home/

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 6/22

    newserver:/home

    Reply

    10 Charles Witt January 31, 2007 at 2:55 pm

    Thanks for the howto. This is really close to what I have been looking for. In my particular situation

    LDAP and NIS do not fit as well as your howto does. Also thanks for the comments of everyone, asthey are helpful.

    Reply

    11 exi February 5, 2007 at 1:14 pm

    you might wanne consider runing sshfs on your new server, then u can login to the old (if sshd is

    running) and simply copy the requierd data true fx. mc, and get all the file rights w you

    its fast is simpel, and you only need to have secure shell intstalled on the old box`s to make it work

    (and most boxses have ;)

    just a littet advice for the data moving part.

    Reply

    12 Phil February 9, 2007 at 7:45 am

    I have a problem, for starters, it look lie I was kind of doing the right thing myself but this blog really

    helps, thanks. Anyway everything works fine untill I get to the bit where I am extraction all the users

    data from the home.tar.gz. (kind of important bit) and it fails with text flying up the screen saying

    Cannot change ownership to uid 511, gid 511 and Cannot mkdir: Permission denied and Cannotopen: Permission denied

    obviously I do not have permissions :o(

    I am loged in as root and the home directory of the new server has these permissions:

    drwxrwxrwx 12 root root 0 Feb 8 19:28 home

    Im not sure how it is possible to obtaim more permissions than that. I have tried with other privilages

    on the home directory and it still does it.

    PLease can someone help me

    Many thanks

    Phil

    Reply

    13 GT4NE1 February 14, 2007 at 6:06 pm

    Dont forget about migrating cron jobs.

    /var/spool/cron

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 7/22

    Anything else we havent thought of?

    Reply

    14 aleksb April 17, 2007 at 9:45 am

    Hi!

    I tried your howto, and everything went along great until i rebooted and tried to log on with the users i

    just copied over. root works fine. The passwords are not accepted, and i cannot change them with

    passwd. passwd: Authentication token manipulation error. Im using fedora core 6.

    Please help

    Aleks

    Reply

    15 aleksb April 17, 2007 at 9:58 am

    Nevermind, figured it out :)

    Were missing a statement in the shadow file copy thingamabob

    Reply

    16 vikrant v mankar April 24, 2007 at 1:23 pm

    hi i am new user in linux i am getting every answer from ur site.you are providing great solution on

    every problem its being great to refer your site thanks for every thing

    Reply

    17 Subhanjan July 19, 2007 at 7:07 am

    Hi,

    I have a small query my new system already has couple of user accounts now I want to transfer the

    user accounts from the old system I have checked both the systems there is no conflicts in UID,GID so

    shall I go ahead with it.

    Subhanjan

    Reply

    18 Subhanjan July 19, 2007 at 12:38 pm

    Hi,

    The things worked beautifully for me.

    Thanks to the author.One more thing cant I script the steps that are done by the command awk?

    Subhanjan

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 8/22

    19 NewLinuxUser August 23, 2007 at 6:13 pm

    I was able to migrate the home folders and accounts from RedHad Linx to Fedora but it seems that Icannot log in with the migrated accounts although I am able to see them under USERS. Am I missing

    anything? Please help.

    Reply

    20 Prashantshant August 27, 2007 at 8:02 am

    I am very much thankful that I got migration solution of user. How to transfer printer settings of each

    user from one m/c to another? we have localy connected the printers to thin clients.

    Reply

    21 Paul Douglas Franklin September 19, 2007 at 6:30 pm

    Thank you so much. This is beautiful. Im trying to upgrade to a new physical box, different distro,switch to ldap, and from Samba 2 to Samba 3. All this without messing up the working server. Ive

    messed up the new box several times, and your migration page is very helpful in avoiding mistakes

    during this stage. BTW, I used rsync instead of tar for the home directories.

    Reply

    22 asaguru October 10, 2007 at 10:40 am

    now i am using centos 3 in a dell server now in that server i am running sendmail squid and iptables ftp

    now i want to migrate the server in to new dell server running in centos 5

    please any one help me on this issue

    Reply

    23 RaM October 30, 2007 at 8:51 am

    hi

    everyone i have question im a newbie admin can anyone give me advise or help me if how can i

    backup my old linux email server III to new one or migrate to cent mail..tnx what are the important files

    to back up for linux suse email server III?

    Reply

    24 Eliena Andrews November 27, 2007 at 10:12 am

    hii,

    i followed the procedure above, after all steps. USers password is not getting accepted, what could

    have went wrong ?

    Eliena Andrews

    Reply

    25 Kevin Smith December 24, 2007 at 10:28 pm

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 9/22

    I cut and pasted the commands into an SSH terminal & checked the passwd.mig and shodow.mig to

    find they were empty!

    I double checked the lines and they were correct (values ect.)

    Plus I end up with a file called - which Im guessing comes from the /etc/shadow line tee - (typomaybe?)

    Id really like to get this working as it would be quite helpful with my project. My Level is slightly above

    newbie Admin.

    Kev

    Reply

    26 mj40 February 6, 2008 at 1:51 am

    First of all i just wanna say thank you guys! This is my first time to get into the linux world! .

    I follow the instruction regarding how tos .. then after rebooting my new centos5 box error message

    appears:

    The user database cannot be read. The problem is most likely caused by a mismatch between/etc/passwd and /etc/shadow or /etc/group and /etc/shadow. The program will exit now.

    I follow the instructions twice and i got same message error. I dont know how to fix this one. Please

    help me

    Thanks.

    Reply

    27 Augusto February 19, 2008 at 8:34 pm

    this how to works great :) But now Im stuck i need to migrate from Redhat to Debian the UGIDLIMIT

    are different on this distros? any advice ?

    thanks

    Reply

    28 Betty Harvey June 17, 2008 at 12:27 pm

    Great instructions easy to follow!!! Worked like a charm!! Thanks for making this available I

    have it bookmarked for when I do this again!

    Reply

    29 Peter Thomson June 18, 2008 at 1:49 am

    RE: Augusto need to migrate from Redhat to Debian the UGIDLIMIT are different on this

    distros

    this advice would be useful for me too. Is it possible to adjust the /etc/passwd and /etc/group files?

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 10/22

    30 Brett Knights June 26, 2008 at 5:38 pm

    Thanks, This was very useful.

    I needed to move a couple of system accounts

    so did this:

    awk -F: '($1 ~ /(tomcat|apache)/)' /etc/passwd > /root/move/passwd.mig

    awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd >>

    /root/move/passwd.mig

    and then couldnt figure out what the tee gave me and I was moving a set of users not based on UID

    so did this:

    awk -F: '{print $1}' /root/move/passwd.mig |egrep -f - /etc/shadow >

    /root/move/shadow.mig

    HTH

    Reply

    31 Debbie August 8, 2008 at 8:14 pm

    Fabulous! Routine worked great! Thanks for posting it, saved me a ton of time.

    Reply

    32 Bryan August 26, 2008 at 4:34 pm

    Also a couple of commands to check out if you are having problems with User database cannot be

    read error: pwconv, grpconv and pwck. Works like a charm now :)

    Reply

    33 Miro October 16, 2008 at 6:16 pm

    OK, I followed instructions got stuck with users not being able to log in. If instructions were not

    correct, how do I fix it now?

    Reply

    34 Alan November 7, 2008 at 11:30 am

    Excellent! I followed the instructions and did a fresh install of openSuse 11.0 on to 10.3. I have my old

    /home on a separate partition and didnt mount it during install because Suse wants an initial user which

    would have overwritten my original first user (UsId=1000). I installed, logged in as root, deleted the

    initial user, changed the mount of /home to point to my old /home partition, did the transfer of backed

    up passwd files etcetera, rebooted and bingo!

    My only worry was, when it came to generating the initial user during install, I had a choice of

    encryption algorithms for the password. Obviously if Id chosen the wrong one Id be stuck (though I

    could probably log in as root and reset the users passwords).

    So my question is: is it possible to tell what encryption algorithm was used for password storage before

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 11/22

    starting?

    Thanks again for the info.

    Alan.

    Reply

    35 Dominic November 26, 2008 at 10:39 am

    I am wanting to mirror users/groups to from one Ubuntu server to another. I see that Ubuntu starts off

    with a user with UID 1000 (created with the name you give it in setup), I guess I should not try to

    migrate this user since it already exists on the destination machine i.e. I should set UGIDLIMIT=1001?

    What if one re-runs this action later to update the mirror? Do users gets duplicated cos surely one gets

    multiple entries for same user in /etc/passwd?

    Reply

    36 Mike December 17, 2008 at 2:31 am

    Great Doc. I was able to migrate a CentOS system to a VM.

    Reply

    37 Ganymede January 9, 2009 at 9:09 pm

    My $0.02: For those who are concerned about UIDs and GIDs

    you can change UIDs and GIDs on the old system before migration using:

    groupmod -g (newgid) groupnameusermod -g (newgid) username OR usermod -G (newgid) username

    (g changes the initial group or G to add an additional group membership)

    Make a backup of the old files first and then change the group GID then change any appropriate users

    attached to those groups if necessary. Test to make sure all is well. You can do this preemptively if youare going to from a system that starts custom groups at 500 to one that starts custom groups at 1000or if you dont want any UID/GID conflicts with your target system. Be the superuser and it would also

    be prudent to make the changes while none of the users are attached.

    Feel free to pick this post apart.

    Reply

    38 KPryor January 10, 2009 at 10:41 pm

    Very very helpful. Im going to be needing to do this soon and didnt really know how to proceed.

    Thanks!KP

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 12/22

    39 Joe Riley February 5, 2009 at 8:19 am

    Your FAQ fails to copy over /etc/passwd- as well

    in the command:

    cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    should be:

    cp /etc/passwd /etc/passwd- /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak

    Reply

    40 Shawn February 17, 2009 at 4:16 pm

    Fantastic instructions. A+++

    Thanks.

    Reply

    41 gczman March 2, 2009 at 3:35 pm

    copied the mboxs from one unix box and the /etc/passwd and /etc/shadow and it worked perfectly.thanks

    Reply

    42 waloyce March 24, 2009 at 4:26 am

    Thanks the howto is very useful.But how to migrate the virtual users and domains accounts to a newserver

    Reply

    43 Denis March 30, 2009 at 5:07 am

    Great instructions, worked well for me

    BTW, if I had 2 linux servers, do you think it would be possible to merge the accounts into one of the2 ?

    Reply

    44 roshan April 6, 2009 at 10:30 am

    your cp & awk command is so good

    Reply

    45 fidel April 23, 2009 at 10:44 am

    thanks for this small & easy how-to

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 13/22

    Worked like a charme

    Reply

    46 Juan Carlos June 15, 2009 at 2:30 pm

    there is something similiar for Solaris ?

    Reply

    47 Vivek Gite June 15, 2009 at 2:49 pm

    @Juan,

    Solaris uses the same files /etc/passwd and friends. So it should work with a little modification.

    Reply

    48 mstone June 16, 2009 at 5:24 pm

    Also check for aliases because a common multiple recipients solution uses that technique

    Reply

    49 Andy July 29, 2009 at 8:00 pm

    If you use Samba shares; remember to grab /etc/samba/smb.conf, /etc/samba/smbusers, and/etc/samba/smbpasswd

    Reply

    50 John Wood April 1, 2010 at 3:51 pm

    I was getting a - file created in /root/move when trying to get the shadow.mig, but Im not now, and

    Im not sure what I did!

    If anyone does get the - file, add some spaces around the tee command and try again Thatswhat I did and it went away!

    Reply

    51 John Wood April 1, 2010 at 3:55 pm

    no, wait, I wasnt looking in the current directory I actually dont get rid of the - file

    Reply

    52 Lukas Johansson August 17, 2010 at 11:52 pm

    Thanks for this guide, managed to migrate a large webserver without any major problem thanks toyou!

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 14/22

    53 Embedded October 6, 2010 at 1:32 pm

    Thanks for a great guide.

    I have small problem with it.

    From some reason the tar commands dont work under Red Hat Linux.it did not manage to tar or untar the files.

    Do you know how to skip existing files?I tried -k flag but no success ;/

    Reply

    54 Ryan October 14, 2010 at 8:42 pm

    Everything worked great. All my users & machines show up in User Manager.

    However I cannot logon as a user, only root. It says wrong password.

    Reply

    55 Tim November 29, 2010 at 3:45 am

    In Ubuntu, I had a problem following these instructions. When the screensaver was locked, youcouldnt unlock the screen without going to Switch User and then put in the password there. In

    addition, half of the time your gdm session would immediately crash and youd have to log in fromscratch again.

    The problem was that the shadow user wasnt able to read the /etc/shadow and /etc/gshadow files.The /etc/shadow and the /etc/gshadow files need to be chownd to root:shadow, and chmodd to 640like this:

    # chown root:shadow /etc/shadow# chown root:shadow /etc/gshadow

    # chmod 640 /etc/shadow /etc/gshadow

    Reply

    56 Irek May 13, 2011 at 4:16 pm

    I tried to move account details from SUSE to Fedora/RH and password is not working :(I

    Reply

    57 Manojg August 1, 2011 at 11:09 pm

    I created account successfully, can login but login take time and gives error:

    /usr/bin/xauth: timeout in locking authority file /home/testuser/.Xauthority

    Any help?

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 15/22

    58 kaleeswari August 18, 2011 at 6:57 am

    how to create the another root user and how to change the root ?

    Reply

    59 kaleeswari August 18, 2011 at 6:59 am

    how to transfer the files from one root to another root user in same system using ubunto or fedora?

    Reply

    60 Chris September 26, 2011 at 6:07 pm

    This worked perfect for me migrating users from an old FC3 box to a new Ubuntu 10.04 LTS one. Idid run into a problem when I tried to do it a second time. The instructions as they are will result induplicate entries in the /etc/passwd file. If you want to do this more than once, the *.mig files will need

    some manual massaging before catting into the destination passwd file. (This may go without saying formost of you, but for me it wasnt something I thought of ahead of time). I was able to clean it up, but it

    was a pain.

    Reply

    61 Frank Wang October 12, 2011 at 8:43 am

    For the /etc/shadow file, better use following to prevent ambiguous match, say a local account nameddb will also match system account dbus

    # awk -v LIMIT=$UGIDLIMIT -F: ($3>=LIMIT) && ($3!=65534) {print $1} /etc/passwd | sed -r -e s/(.*)/^\1:/ | egrep -f /etc/shadow > /root/move/shadow.mig

    Reply

    62 Paul December 11, 2011 at 8:50 pm

    It worked perfect from FC 11 to FC 15. Btw, may I add the fact that the host keys must be

    imported/ecported also. Reason: it is possible to have some users which are using their accounts(SFTP) with the help of an automaitc SFTP client. IN order to keep everything transparent for them,

    the host keys of the machine must be imported/exported (etc/ssh).Maybe is better to test it and include it in this tutorial. Btw, the a lot for doing this.

    Have a nice weekend.

    Paul

    Reply

    63 Montaser Islam December 12, 2011 at 11:59 am

    cool post;it save a lot of time man.

    Reply

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 16/22

    64 tem_dl April 5, 2012 at 3:24 am

    cool tip. im using it. :D. tks so much

    Reply

    65 wfade April 19, 2012 at 8:21 am

    oki think that you should awk at the new system for combine the new file that you had cp

    Reply

    66 AA April 25, 2012 at 12:55 pm

    I am migrating accounts between an RHEL 5 server and RHEL 6 server and noticed that etc/gshadow

    file entries for even the same group are listed differently between the two servers. For example: ntp:!::on rhel 6 and ntp:x:: on rhel 5. Your wonderful article shows that the gshadow file is copied in itsentirely (as is) from the old server to the new server. This means that the entries on the new server will

    be completely replaced. Would it be better to append entries from the original gshadow that dontexist on the new server instead of replacing it with the entire file from the old server? Thanks in

    advance.

    Reply

    67 Francisco Prez May 25, 2012 at 5:27 am

    Gracias por su procedimiento:Solo una pequea sugerencia / pregunta:

    No sera mejor en lugar de:

    Copia el archivo / etc / gshadow (rara vez utilizada):# cp /etc/gshadow /root/move/gshadow.mig

    Usar el mismo procedimiento que para shadow?:awk -v LIMIT=$UGIDLIMIT -F: ($3>=LIMIT) && ($3!=65534) {print $1} /etc/group | tee

    |egrep -f /etc/gshadow > gshadow.mig

    y ya en el nuevo servidor, en lugar de:

    # /bin/cp gshadow.mig /etc/gshadow

    hacer lo mismo que con los otros archivos:# cat gshadow.mig >> /etc/gshadow

    Un saludo afectuoso..

    Reply

    68 ed June 10, 2012 at 9:38 pm

    Great help!

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 17/22

    Thanks

    Reply

    69 Steve Kelem June 26, 2012 at 10:18 pm

    Francisco: (My Spanish is good enough to understand you, but not enough to answer)

    Your script grabs every user name above UGIDLIMIT and then grabs every matching line fromgshadow.

    1. If a user matches the UGID, and is in a group that already exists on the new machine, e.g., adm,disk, lp, man, dialout, lpadmin, then you get two entries for those groups in the new gshadow.

    2. There is a small (but non-zero) chance that a users name is a substring of a group that doesntmatch UGID, then you would get false positives: roo, kern, hal, ack, kit, and other 3-letter initials thatsome users might (perhaps unwisely) use. The grep should check for lines with words that match

    exactly the usernames.

    Reply

    70 mark July 8, 2012 at 8:54 pm

    I keep getting permission denied when i attempt to create the shadow.mig ???

    I added my user to the root group but no difference

    -rw-r 1 root shadow 982 2012-04-19 13:28 shadow are my permission group has read

    Reply

    71 John August 22, 2012 at 4:02 pm

    Wow, you know youve got a great tutorial when its copied verbatim by a bunch of others who dontgive one bit of credit to the original.

    I have found this on at least 5 other sites with only ONE giving credit to Vivek and cyberciti.biz.

    Reply

    72 ian scott-fleming August 29, 2012 at 4:07 pm

    Is there a reason you use !=65534 instead of =LIMIT) && ($3=LIMIT) && ($3

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 18/22

    Great post! Thanks for this :-)

    Reply

    74 PhilipV October 19, 2012 at 2:50 am

    I did it successfully. Thanks.

    Reply

    75 dali October 29, 2012 at 3:57 pm

    think you..

    Reply

    76 Jeremy December 12, 2012 at 4:46 pm

    I followed your instructions to migrate from redhat kernel 2.4 to centos 6 and for the most part, theyworked great. The only problem I am experiencing is when I go into the user manager I get the error I

    couldnt find the numerical IDs of these groups: and it lists about 10 groups. (ident, mailnull, netdump,news, nscd, pcap, piranha, pvm, rpm, squid, xfs) I didnt see these groups in /etc/group or/etc/gshadow and I am not sure that any of the corresponding programs are loaded on the new

    machine. Any help on this would be greatly appreciated. Thanks!

    Reply

    77 Jeremy December 12, 2012 at 4:51 pm

    Correction. They are in /etc/gshadow but not in /etc/group

    Reply

    78 Jeremy December 12, 2012 at 5:31 pm

    ahhhhhh. I answered my own question after re-reading my last post. All of the programs I listed had

    GIDs lower than 500. I edited the the /etc/group file (vigr) and inserted the missing values. All is wellnow. Thanks for the awesome post.

    Reply

    79 metalmas January 1, 2013 at 9:17 am

    Unfortunately this tutorial doesnt working when I tried migrate user with mailboxes from Fedora do

    CentOS, because when I start postfix + dovecot a lot of error with permissions denied occured inmaillog and email klients could not connect :(

    Reply

    80 gamezat February 14, 2013 at 11:53 pm

    thank you so much,

    very useful i moved from server to anthor without any problems

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 19/22

    thank you

    Reply

    81 ion March 1, 2013 at 2:35 pm

    Thank you

    Reply

    82 ilde March 26, 2013 at 7:20 am

    HiA very simple and effective approach, which I followed. Then, to copy all directories in /home

    directory, I used next command as root:rsync -avz /home/ 192.168.0.15:/home

    Where /home/ refers to the source machine, and 192.168.0.15 is the IP address of the destination one.All file permissions and ownerships were preserved. Also please make sure you include all slashesshown.

    rsync must be installed in both the source and the destination boxes. Both machines are servers whichrun Debian Squeeze.

    Thanks

    Reply

    Leave a Comment

    Name *

    E-mail *

    Website

    You can use these HTML tags and attributes for your code and commands:

    Notify me of followup comments via e-mail

    Submit

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 20/22

    Tagged as: awk command, encrypted password, etc passwd, linux distribution, linux server, linux system, old server, scpcommand, tar ball, user account migration, user accounts

    Previous Faq: Create a mysql database, tables and insert data

    Next Faq: How to test or check reverse DNS

    GET FREE TIPS

    Make the most of Linux Sysadmin work!

    Enter your email Sign Up

    Youtube | Twitter | Google +

    nixCraft

    Like

    32,043 people like nixCraft.

    Facebook social plugin

    Related Faqs

    How do I know When I Need To Update My Linux SystemSoftware?

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 21/22

    Understanding /etc/shadow file

    Reboot Linux System Command

    UNIX / Linux Command To Check Existing Groups and Users

    Understanding /etc/passwd File Format

    Linux deny or block user login

    Linux / Unix AWK: Read a Text File

  • 4/20/13 Move or migrate user accounts from old Linux server to a new Linux server

    www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/ 22/22

    How To Test Linux Operating System for IPv6 Networking Support

    Linux What defines a user account?

    Linux Upgrade Password Hashing Algorithm to SHA-512

    2006-2013 nixCraft. All rights reserved. Cannot be reproduced without written permission. Privacy Policy | Terms of Service | Questions or Comments | Sitemap