Migrating etc password file from Red Hat 9 to Enterprise

Posted on 2005-04-13
Last Modified: 2013-12-06
We need to know if there is a way or tool to migrate the etc password file from 9 to enterprise. This is an extremely URGENT issue, so if you could respond quickly it would be greatly appreciated. Please let me know if you need more information.. As I am a novice to Linux.. Thanks in advance!!

Question by:onsite_tech
    LVL 23

    Expert Comment

    I don't have the specifics for Enterprise's peculiarities, but the same kind of password file
    ought to work on both systems, unless one has customized it.

    But if you want to Migrate  /etc/passwd over
    you will also need to migrate over   /etc/shadow

    And possibly

    To move users' group ids over as well

    /etc/passwd   is the file that should be publicly readable (by all users of the system)
    and just contains the user database  for use by the basic commands

    /etc/shadow     is the file that contains actual matching passwords for all the users,
    and should be readable only by root.

    The format for the files is fairly typical, though the encryption methods/settings may differ
    between releases or systems

    Try  /etc/libuser.conf    for settings details
    if both systems have it, and/or they both have the same cryptstyle,
    then the password configuration should be basically interchangeable,
    I think.. so long as all the password files make it over in the migration
    LVL 48

    Expert Comment

    If you haven't changed any defaults, you can simply copy across


    LVL 38

    Expert Comment


       Before you copy over those 3 files which other experts suggested, please make a copy of them.
    cp /etc/passwd /etc/passwd.original
    cp /etc/shadow /etc/shadow.original
    cp /etc/group /etc/group.original

       After copying over those files, compare
    /etc/passwd amd /etc/passwd.orig
    and check for the system account with user account, make sure the old user account in /etc/passwd doesn't have the
    same UID as the new system/service account in /etc/passwd.orig.
    It yes, then change the UID of system account or user account.
    LVL 1

    Author Comment

    we ended up finding a redhat "unoffical" migration script that snagged all of the users and thier home dirs and threw them into a tar file.  that worked great (if a bit slow) and we migrated it over to the new server, but now we have a problem cause the tar file is 5 gigabytes and every time we try to do anything with it (view the files in it or extract it) it just kinda sits there and doesn't really do anything (the process load on the box doesn't go up, it just sits there).

    anyone have any ideas on how to handle files this big and untarring them?
    LVL 38

    Expert Comment

    Could you post the URL of the migration script, which you downloaded?
    You might need to modify the script for the tar to archive into separate small tar.gz files.
    LVL 48

    Expert Comment

    What happens when you do:

    strace tar ztvf tarfile.tgz

    LVL 1

    Author Comment

    i'm having a hard time finding the actual page on redhat's site but here is the script itself:

    # * by Chris Kloiber <>
    # Quick and dirty hack to migrate user and group data from a sick
    # machine to a new machine. This script is provided "AS-IS", and is
    # licenced to you under the GPL, which as always can be downloaded
    # from
    # Although I work for Red Hat, Inc. this script is not a product
    # of Red Hat, Inc. It has not been through QA other than my own
    # testing. It might eat your data, but it didn't eat mine. YMMV.

    if [ $CUSTOMIZED = 'no' ]; then
            echo "Take a moment to edit this script to customize it";
            echo "for your particular environment. Edit this script";
            echo "and change the CUSTOMIZED variable to 'yes' to";
            echo "bypass this message.";
            exit 0;

    # This backup uses 'tar', you get to choose the compression.
    # You can specify a /location/filename for the tar.

    # Leave off the file extention. It will be added based on COMPRESSION
    # BACKUP_PATH=/mnt/dist/
    # BACKUP_FILE=$(hostname)-$(date -I)
    BACKUP_FILE=$(hostname)-$(date -I)

    # If you set TAPE_DEVICE, BACKUP_PATH and BACKUP_FILE are ignored.
    # If you don't have a tape drive, leave this blank. (tapes not tested)

    # The choices for compression are: bzip2, gzip or none

    # Be clean (or not, this script is for dying machines afterall)

    # Paths to home and mail, relative to / (but don't include the /)

    # Other variables that should not need changing often, if at all.

    # Here we parse the group, passwd, and shadow files.
    # We do *not* write to the original files, but instead create *.sav files
    # (this part took me several hours to figure out...)

    awk -F ":" -- '{if ($3>='499' && $3!='65534') print}' $GROUP > $GROUP.sav
    awk -F ":" -- '{if ($3>='499' && $3!='65534') print}' $PASSWD > $PASSWD.sav

    for i in $(awk -F ":" -- '{print $1}' $PASSWD.sav) ; do
            awk -v user=$i -F ":" -- '{if ($1==user) print}' $SHADOW >> $SHADOW.sav;
            echo $i >> $USERS

    # Now we have tossed out the system accounts, and have pure user data.
    # It's time to grab the home and mail directories. I will build a list
    # of directories to back up, then use it to make a tarfile.

    echo $GROUP.sav > $BLIST
    echo $PASSWD.sav >> $BLIST
    echo $SHADOW.sav >> $BLIST

    for i in $(cat $USERS) ; do
            echo $HOMEDIR/$i >> $BLIST ;
            echo $MAILDIR/$i >> $BLIST ;

    # Actually make the archive

    cd /
    if [ $TAPE_DEVICE ]; then
            if [ $COMPRESSION = 'bzip2' ]; then
                    tar -T $BLIST -jcvf $TAPE_DEVICE ;
            elif [ $COMPRESSION = 'gzip' ]; then
                    tar -T $BLIST -zcvf $TAPE_DEVICE ;
                    tar -T $BLIST -cvf $TAPE_DEVICE ;
            if [ $COMPRESSION = 'bzip2' ]; then
                    tar -T $BLIST -jcvf $BACKUP_PATH/$BACKUP_FILE.tar.bz2 ;
            elif [ $COMPRESSION = 'gzip' ]; then
                    tar -T $BLIST -zcvf $BACKUP_PATH/$BACKUP_FILE.tar.gz ;
                    tar -T $BLIST -cvf $BACKUP_PATH/$BACKUP_FILE.tar ;
            fi ;

    # cleanup temporary files
    if [ $CLEANUP = 'yes' ]; then
            rm -f $GROUP.sav $PASSWD.sav $SHADOW.sav $USERS $BLIST

    echo ""
    echo "You are done on this end. (Yay!)"
    echo ""
    echo "When you have extracted the archive on the target machine there is"
    echo "still some work to be done. You will need to add the user information"
    echo "found in the /etc/*.sav files to the end of the new system's"
    echo "/etc/group, /etc/passwd and /etc/shadow files. You must do this while"
    echo "making sure there is no overlap of uid or gid numbers. This will"
    echo "usually happen for uid=500 if you created a user account on the new"
    echo "machine during install. Just be aware of it, it's not hard to fix."
    LVL 38

    Expert Comment

    > for i in $(cat $USERS) ; do
    >         echo $HOMEDIR/$i >> $BLIST ;
    >         echo $MAILDIR/$i >> $BLIST ;
    > done
    Comment out this portion and move over the home direcotry and mail folder manually.

    In this script, it assumes all the home directories are under /home
    and all the unread mails are under /var/spool/mail
    LVL 1

    Author Comment

    I figured out why the tar file wasn't working correctly.  the partitions on this box were loaded weird and the disk i was extracting it to didn't have enough space.  it works fine now though.  pretty cool script.

    Accepted Solution

    Closed, 500 points refunded.
    Community Support Moderator (Graveyard shift)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now