Solaris Troubleshooting NIS: add a user for NIS maps when passwd file is not in the /etc directory

Below procedure can be used to add a new NIS user when the passwd file is not in the /etc directory

Steps to Follow

The example below demonstrates how to add a user for NIS maps when the passwd file is not in the /etc directory.

The NIS directory is /etc/nisdir, where all the NIS maps reside.

Create a user in the /etc/passwd file. In this example, the new user is Johnl

Step 1.

Edit /etc/passwd to Add entry for the user

# vi /etc/passwd

Johnl:x:107:14:John l:/export/home/johnl:/bin/csh

Assign a password to the new user.

passwd johnl

Step 2:

Now run below command to create an entry in the shadow file

# pwconv

cat /etc/shadow file to see this entry in there.


Step 3:

Just copy the new entries to the /etc/nisdir/passwd file for passwd entry, and /etc/nisdir/shadow for shadow entry. To update the passwd map and push it to the slaves.

# make passwd

**NOTE**If you do not want this new user to be a local user, delete the entries in /etc/passwd and /etc/shadow.



I have started ( aka in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' You can connect me at -

8 Responses

  1. Sukhbir Singh says:

    Hello dear
    its good but not clear copy which entry to which file like from passwd to which file and from shadow to which file or only one entry is sufficient

  2. Ramdev says:

    Hello Sukhbir.

    entry “Johnl:x:107:14:John l:/export/home/afzal:/bin/csh” from /etc/passwd to /etc/nisdir/passwd and entry “johnl:dhXRywfkSELcE:10091::::::” from /etc/shadow to /etc/nisdir/shadow.
    hope this helps

  3. Sukhbir Singh says:

    Thanks Ram
    its now clear
    Thnx a lot
    Have a good day……….

  4. Ravi says:

    why pwconv here

    • Ramdev Ramdev says:

      @ravi, Since we added the new user by manually editing the /etc/passwd, we want to get the corresponding entries in /etc/shadow with pwconv command. Alternatively we can edit the /etc/shadow for the entries without using the pwconv.

  5. Gavin Reid says:

    Thats a very messy way , take a look at Perl an Unix::PasswordFile modules :

    heres my password reset scripts for an example :

    #!/usr/bin/perl -w
    use Unix::PasswdFile;
    my $PASSWORDFILE = “/var/yp/src/passwd”;

    use strict;
    unless (@ARGV >= 1) 
            print “nBetter if you supply a username !n”;
            exit ;
    # now generate the random password and get the forgetful user name
    chomp(my $ranpass= `/usr/sfw/bin/openssl rand -base64 6`);
    chomp(my $user= shift);

    #open the password file 
    my $pw = new Unix::PasswdFile $PASSWORDFILE;
    if (!defined $pw->user($user))
            print “n try to supply a valid username …. moronn”;
            print “n now we are all laughing at you .hahahaha n”;
            exit ;
    $pw->commit() or die “cant commit passwd files changes :$1”;
    # Rebuild NIS maps
    print “nBuilding NIS maps…n”;
    system(“cd /var/yp && /usr/ccs/bin/make”);
    print “nn————— CUT and SEND to USER ———-n”;
    print “Your password has been resetn”;
    print “Username:          $usern”;
    print “Password:          $ranpassn”;
    print “n ——————–END CUT ——————-n”;

  6. Ramdev Ramdev says:

    Thanks Gavin for providing the script, really appreciate your time.

  1. November 9, 2011

    business tips make mones web service…

    […] » Solaris Troubleshooting NIS: How to add a user for NIS maps when passwd file is not in the /etc directory[…]…

What is in your mind, about this post ? Leave a Reply

  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us