Add a user from the command line in Solaris
Posted by Quinn McHenry in 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.
About Quinn McHenry
View more articles by Quinn McHenry
The Conversation
Follow the reactions below and share your own thoughts.






November 06, 2008 at 7:03 pm, question said:
but what’s fred’s password when you want to log on with fred??
November 10, 2008 at 8:19 pm, fred said:
still, as root, run ‘passwd fred’ to set fred’s password.
December 12, 2008 at 1:25 pm, Anonymous said:
# passwd -r files fred
for completness since it specifies that you are changing the local passwd file and not nis/ldap.
March 30, 2009 at 8:06 pm, Orion said:
then ‘passwd -f fred’ to force him to change password on next login
November 04, 2010 at 4:52 am, Henrydenial said:
# 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
February 22, 2010 at 2:40 pm, Anonymous said:
thanks very much i reset my password
September 07, 2010 at 4:31 am, Naveedmirk said:
how to add new home directory fred
November 04, 2010 at 5:03 am, Henrydenial said:
how to create passwd setting for a group ?
October 08, 2011 at 12:02 am, mrsun said:
u r awsome fred .. thanks a ton .. u have explained it in a beautiful manner .. god bless u
April 10, 2013 at 1:30 pm, anon said:
> ahh
January 23, 2012 at 10:51 pm, saran said:
how to create more than five user in a single command without using script in solaris
March 07, 2012 at 3:05 pm, Chris H said:
Just created some users on my test box, I noticed all my users have been givien a gid value of 1. Does gid mean group id? If so how can I create a new user with a different gid, so that I can alter permission strings to restrict access etc etc.