Add a user from the command line in Solaris

Contributor Icon Contributed by qmchenry  
Tag Icon Tagged: Solaris system administration  

This shows how to use useradd in Solaris to add a user.

You must be root (superuser) to add a user. An easy way to remember the syntax of the useradd command in Solaris is to run it with no options. Follow the resulting usage information including the parts that you require. Important options are:

-d home-directory-path
This is the new user’s home directory, typically /export/home/username

-m
make home directory and copy the default skeleton files (these files are located in /etc/skel directory).

-u uid
The uid (userid) is a number from 0 to 65535 which identifies the user on the system. uid 0 is reserved for root. If you don’t specify one, the next available uid will be used automatically.

-c “User Name”
Comment field which usually contains the name of the user. Make sure you enclose the name in quotes if it contains a space.

-s /path/to/shell
The shell to use. If you don’t specify this, it will default to /bin/sh. Make sure you specify the fully qualified path.

So, putting it together, a typical addition of a user named fred would be:

useradd -d /export/home/fred -m -s /bin/ksh -c "Fred Smith" fred

It’s a smart idea to run pwck (passwd check) whenever you make a change to the /etc/passwd file (as when adding or changing a user). This program will identify any problems with the passwd file. If it doesn’t tell you anything, then you are in good shape.

 

10 Comments -


  1. question said on November 6, 2008

    but what’s fred’s password when you want to log on with fred??

  2. fred said on November 10, 2008

    still, as root, run ‘passwd fred’ to set fred’s password.

  3. Anonymous said on December 12, 2008

    # passwd -r files fred

    for completness since it specifies that you are changing the local passwd file and not nis/ldap.

  4. Orion said on March 30, 2009

    then ‘passwd -f fred’ to force him to change password on next login

  5. Anonymous said on February 22, 2010

    thanks very much i reset my password

  6. Naveedmirk said on September 7, 2010

    how to add new home directory fred

  7. Henrydenial said on November 4, 2010

    # passwd -f username

    this wil change the passwd ……then u can set a new password for user ….for these thing u should be a root user

    regards
    henry
    solaris system admin
    pune

  8. Henrydenial said on November 4, 2010

    how to create passwd setting for a group ?

  9. mrsun said on October 8, 2011

    u r awsome fred .. thanks a ton .. u have explained it in a beautiful manner .. god bless u

  10. saran said on January 23, 2012

    how to create more than five user in a single command without using script in solaris

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -