23.3 Creating User Accounts

To create a user account by using the useradd command:

  1. Enter the following command to create a user account:

    # useradd [options] username

    You can specify options to change the account's settings from the default ones.

    By default, if you specify a user name argument but do not specify any options, useradd creates a locked user account using the next available UID and assigns a user private group (UPG) rather than the value defined for GROUP as the user's group.

  2. Assign a password to the account to unlock it:

    # passwd username

    The command prompts you to enter a password for the account.

    If you want to change the password non-interactively (for example, from a script), use the chpasswd command instead:

    echo "username:password" | chpasswd

Alternatively, you can use the newusers command to create a number of user accounts at the same time.

For more information, see the chpasswd(8), newusers(8), passwd(1), and useradd(8) manual pages.