Add a user from the command line in Solaris

Home -> UNIX -> Solaris -> System administration

88937 views

From the computer of: qmchenry (338 recipes)
Created: Aug 17, 2003     Updated: Nov 28, 2003


Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

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 chaning 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.

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Change BootPROM settings from the Solaris command line
  Solaris 10: connect or login to zone console
  Read BootPROM settings from the Solaris command line
  Configure Solaris for DNS resolution of hostnames
  Display Solaris system configuration with prtconf
  Solaris: list installed packages with pkginfo
  Solaris 10: shutdown or stop a zone
  Solaris 10: enable NFS server
  Solaris: Create a mount point
  Login to Solaris desktop from Windows using Cygwin

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.