LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Question about transferring system

[ILUG] Question about transferring system

kevin lyda kevin+dated+1082356907.59b388 at ie.suberic.net
Wed Apr 14 07:41:37 IST 2004


On Wed, Apr 14, 2004 at 01:50:43AM +0100, bobb wrote:
> Michael Treacy hath declared on Tuesday the 13 day of April 2004  :-:
> > >Could he not just add the users and groups change the uid and gids in the
> > >/etc/passwd and /etc/groups to suit the old system and mount the old drives
> > >/home as /home ??
> > 
> > Only problem is, I have a few hundred users, 'cos its a server in a school 
> > lab! I'd rather not have to add them all again if I didn't have to....
>  
> Yeah... you will probably get away with just copying over the old 
> password files... however you should take care doing it, there may
> be new important system accounts in the defailt password files in 9
> Things might go a little screwy if they are missing or there are
> incorrect entries....

most adduser tools create user accounts with uids greater then a certain
number (on redhat it's > 500).  so a bit of perl could rip out all the
user accounts from the old passwd/group/gshadow files.  something like:

    # assumes old disk is mounted in /mnt and that user uids
    # start at 500
    open(P, "</mnt/etc/passwd");
    open(NP, ">/root/new.passwd");
    while (<P>) {
        @l = split(/:/);
        if ($l[2] >= 500) {
            print NP $_;
            $gid{$l[3]} = 1;
            $login{$l[0]} = 1;
        }
    }
    close(P);  close(NP);

    open(G, "</mnt/etc/group");
    open(NG, ">/root/new.group");
    while (<G>) {
        @l = split(/:/);
        if ($gid{$l[2]} == 1) {
            print NG $_;
            $group{$l[0]} = 1;
        }
    }
    close(G);  close(NG);

    open(G, "</mnt/etc/gshadow");
    open(NG, ">/root/new.gshadow");
    while (<G>) {
        @l = split(/:/);
        if ($group{$l[0]} == 1) {
            print NG $_;
        }
    }
    close(G);  close(NG);

    open(S, "</mnt/etc/shadow");
    open(NS, ">/root/new.shadow");
    while (<S>) {
        @l = split(/:/);
        if ($login{$l[0]} == 1) {
            print NS $_;
        }
    }
    close(S);  close(NS);

then just append the new.* files to their respective files in /etc.

kevin

-- 
kevin at ie.suberic.net  ~  Would you put on your resume that 3,000 people
                         died due to your failure while you were in charge?

                         So why is George Bush?


More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell