Creating User Accounts
Use the useradd
and passwd
commands to create a user and set a password.
-
To create a user account using the default settings, enter the following command:
sudo useradd [options] username
By default, if you specify a username argument with no other options,
useradd
creates a locked user account using the next available UID and assigns a user private group (UPG) rather than the value defined forGROUP
as the user's group.Note:
Valid usernames contain only lowercase and uppercase letters, digits, underscores (_), or dashes (-). Dashes aren't allowed at the beginning of the username. The username can end with a dollar sign ($). Fully numeric usernames and usernames . or .. aren't allowed.
-
Assign a password to the account, by entering the following command.
sudo passwd username
The command prompts you to enter a password for the account.
To change the password noninteractively (for example, from a script), use the
chpasswd
command instead:echo "username:password" | chpasswd
You can use the newusers command to create several user accounts at
the same time. The newusers
command reads the account information from a
text file.
For more information about creating user accounts from the command line, see the chpasswd(8)
,
newusers(8)
, passwd(1)
, and
useradd(8)
manual pages.
To create user accounts with a web-based GUI, see Oracle Linux: Using the Cockpit Web Console.