How to Add a New User in Linux
To answer how to add a new user in linux, you usually create the account with useradd or adduser, set a password, and optionally give the user sudo access. The exact command depends a little on your Linux distribution, but the process is straightforward once you know which tool your system provides.
Quick answer
On many Linux systems, the fastest way to create a new user is:
sudo useradd -m username
sudo passwd usernameIf your distribution uses adduser as the preferred command, you can use:
sudo adduser usernameThe first command creates the user and home directory, and the second sets the password. If the user needs admin privileges, add them to the appropriate sudo group after creation.
What you need before creating a user
You need administrative privileges to add a new account. That usually means you are logged in as root or as a user with sudo access. It also helps to know whether your system uses useradd or adduser, because both can create users, but they do not behave exactly the same way.
- Root or sudo access to create the account
- A username that follows your system’s naming rules
- Optional group membership if the user needs elevated permissions
- Optional shell choice if you want something other than the default shell
Create a user with useradd
useradd is a low-level command available on most Linux distributions. It creates the account, but on many systems it does not set a password or create a home directory unless you specify options.
Basic command
sudo useradd usernameThis creates the user account, but it may not create a home directory or set a password automatically. For most everyday cases, you will want a more complete command.
Recommended command for a normal user
sudo useradd -m -s /bin/bash usernameWhat the flags do:
-mcreates the user’s home directory if it does not already exist-s /bin/bashsets Bash as the default shell
After running that, set a password:
sudo passwd usernameCreate a user with a specific home directory
sudo useradd -m -d /home/username -s /bin/bash usernameUse this when you want to explicitly choose the home directory location. In many cases, the default location is fine, so this option is only needed when you have a specific layout requirement.
Create a user with adduser
adduser is a friendlier interactive tool on Debian, Ubuntu, and some related systems. It often creates the home directory, sets up defaults, and prompts you for the password during the process.
Basic command
sudo adduser usernameDuring the prompts, you will usually be asked to enter and confirm a password. You may also be prompted for optional account details such as the full name or phone number. You can leave those blank if you do not need them.
When to use adduser instead of useradd
- Use
adduserif you want an easier, interactive setup - Use
useraddif you want a script-friendly command with more manual control - Use whichever command is standard on your distribution
On many Debian-based systems, adduser is the more common choice. On many RHEL-based systems, useradd is more common.
Set or change the password
If you used useradd, you usually need to set the password separately. If you used adduser, the password is often set during the account creation prompts, but you can still change it later.
sudo passwd usernameThis command works for setting a first password or changing an existing one. The system will prompt you to enter the new password twice.
Give the new user sudo access
If the new account needs administrative privileges, add it to the correct group. The group name depends on the distribution.
| Distribution family | Common admin group |
|---|---|
| Debian, Ubuntu | sudo |
| RHEL, CentOS, Fedora | wheel |
Debian and Ubuntu
sudo usermod -aG sudo usernameRHEL, CentOS, Fedora
sudo usermod -aG wheel usernameImportant note: the -aG options matter. -a appends the user to the group, and -G specifies the group. If you leave out -a, you can accidentally remove other supplemental groups.
Verify the new account
After creating the user, it is a good idea to confirm that the account exists and has the settings you expected.
Check the user entry
id usernameThis shows the user ID, primary group, and any secondary groups.
Check the account record
getent passwd usernameThis confirms that the account is present in the system’s user database and shows details such as the home directory and shell.
Check the home directory
ls -ld /home/usernameUse this if you want to confirm that the home directory was created and has the expected ownership.
Check group membership
groups usernameThis is useful if you added the user to sudo or wheel and want to confirm the group change.
Common mistakes to avoid
- Forgetting
-mwith useradd, which can leave the user without a home directory - Forgetting to set a password, which makes the account unusable for login
- Using the wrong admin group, such as adding a user to
wheelon a system that expectssudo - Leaving out
-awhen adding groups, which can remove existing group memberships - Assuming adduser exists everywhere, because some systems use
useraddinstead
Examples of common setups
Simple regular user
sudo useradd -m -s /bin/bash alice
sudo passwd aliceInteractive setup on Ubuntu or Debian
sudo adduser aliceUser with sudo access on Ubuntu or Debian
sudo useradd -m -s /bin/bash alice
sudo passwd alice
sudo usermod -aG sudo aliceUser with admin access on Fedora or CentOS
sudo useradd -m -s /bin/bash alice
sudo passwd alice
sudo usermod -aG wheel aliceUseful command summary
| Task | Command |
|---|---|
| Create user with home directory | sudo useradd -m username |
| Interactive user creation | sudo adduser username |
| Set password | sudo passwd username |
| Add to sudo group | sudo usermod -aG sudo username |
| Add to wheel group | sudo usermod -aG wheel username |
| Verify account | id username |
Frequently Asked Questions About how to add a new user in linux
How do I add a new user in Linux from the terminal?
Use sudo useradd -m username and then sudo passwd username, or use sudo adduser username if your system provides that command.
What is the difference between useradd and adduser?
useradd is a lower-level command with more manual control. adduser is usually more interactive and easier to use on Debian-based systems.
How do I give a new Linux user sudo access?
Add the user to the appropriate admin group, usually sudo on Ubuntu or Debian, or wheel on Fedora, CentOS, and RHEL.
How do I create a home directory for a new user?
Use the -m option with useradd, like this: sudo useradd -m username. adduser usually creates the home directory automatically.
How do I verify that a Linux user was created successfully?
Run id username or getent passwd username. You can also check the home directory with ls -ld /home/username.
Can I create a user without a password?
Yes, but it is usually a bad idea for normal login accounts. If the account must be used later, set a password with passwd or configure authentication another way.
Conclusion
The simplest way to add a new Linux user is to create the account, set a password, and verify the home directory and group membership. Use adduser when it is available and you want a guided setup, or use useradd when you want direct control. If the user needs administrative access, add them to the correct sudo-capable group for your distribution.
