How to Create a New Username in Ubuntu

You create a new Unix username in Ubuntu using the useradd command in the terminal, which adds the account to your system's user database. The command takes just one line, but you need to decide a few things first: whether the user should have a home directory, whether they need sudo access, and what shell they'll use when they log in. Most of the time, you'll use a simpler command called adduser instead, which asks you questions and handles the details automatically.

The difference matters: useradd is the low-level tool that does exactly what you tell it and nothing more. adduser is a wrapper around it that creates a home directory, sets up a password, and asks for the user's full name and contact details. For a new account you actually plan to use, adduser is almost always the right choice.

Key Takeaways

  • Use the adduser command in the terminal to create a new username, because it sets up the home directory and password automatically.
  • You must run the command with sudo, which means you need administrator access on the machine.
  • The username must be lowercase, start with a letter, and contain only letters, numbers, hyphens, and underscores.
  • After creation, the new user can log in when ready if you set a password, or you can add them to the sudo group later if they need administrator permissions.

Opening the Terminal and Running the Command

Open the terminal by pressing Ctrl + Alt + T, or search for "Terminal" in your process menu. Type this command exactly:

sudo adduser username

Replace username with the name you want — for example, sudo adduser sarah or sudo adduser dev_user. The system will ask for your own password first, because sudo means "run this as the administrator." Type your password and press Enter. The terminal will not show the characters as you type, which is normal.

Once you enter your password correctly, the system will prompt you to create a password for the new user. Type a password, press Enter, then type it again to confirm. The new account is now created with a home directory at /home/username.

What Happens When You Create the Username

When you run adduser, Ubuntu creates several things at once. It adds an entry to the /etc/passwd file, which is the system's list of all users. It creates a home directory in /home with the same name as the username. It sets up a default shell, usually bash, which is the command interpreter the user sees when they open a terminal. It also creates a group with the same name as the username, which controls file permissions.

The system will ask you for the user's full name, room number, work phone, and home phone — these are optional fields that go into the user's profile. You can leave them blank by pressing Enter, or fill them in if you want. None of this information affects whether the account works; it's just metadata stored in the system.

Rules for Choosing a Username

Unix usernames must follow specific rules, or the system will reject them. The name must be lowercase letters, numbers, hyphens, and underscores only — no spaces, no capital letters, no special characters like @ or !. The name must start with a letter or underscore, not a number. Most systems also limit the length to 32 characters, though shorter names are easier to type.

Avoid usernames that are already taken by the system. Common system usernames include root, bin, sys, daemon, and nobody. If you try to create a username that already exists, adduser will tell you and refuse to create it. You can see all existing usernames by typing cat /etc/passwd in the terminal, though the output is long and hard to read.

Giving the New User Administrator Permissions

By default, a new user can run programs and edit files in their own home directory, but they cannot install software, change system settings, or edit files outside their home. If the user needs to run commands with sudo, you must add them to the sudo group. Type this command:

sudo usermod -aG sudo username

Replace username with the name you just created. The -aG part means "add to group" and sudo is the group name. The user will need to log out and log back in before the change takes effect. After that, they can run commands with sudo by typing their own password when prompted.

Be careful with this step: anyone in the sudo group can change anything on the system, including deleting files or installing malware. Only add users to sudo if you trust them completely.

Checking That the Username Was Created

To confirm the new username exists, type this command:

id username

Replace username with the name you created. The system will print information about that user, including their user ID number, group ID, and which groups they belong to. If the username does not exist, you'll see an error message saying "no such user".

You can also list all users on the system by typing cut -d: -f1 /etc/passwd, which prints just the usernames. This is useful if you forget the exact spelling of a username you created.

Deleting a Username If You Make a Mistake

If you create a username by accident or need to remove it later, use the deluser command. Type:

sudo deluser username

This removes the user from the system but leaves their home directory in place. If you want to delete the home directory too, add the --remove-home flag:

sudo deluser --remove-home username

Be careful with this command — it cannot be undone. Make sure you have backed up any files in that user's home directory before you delete them.

Frequently Asked Questions

Can I create a username without a home directory?

Yes, but you should use useradd instead of adduser. Type sudo useradd -M username, where -M means "no home directory". This is useful for system accounts that run background services, not for people who log in.

What if I forget the password for the new user?

You can reset it from your own administrator account by typing sudo passwd username. The system will ask you to enter a new password twice. The user does not need to know the old password to change it this way.

Can I change a username after I create it?

Yes, use the usermod command with the -l flag: sudo usermod -l newname oldname. This changes the username in the system files, but the home directory keeps its old name. You can rename the directory separately if you want: sudo mv /home/oldname /home/newname.

Do I need to restart Ubuntu after creating a new user?

No, the new user can log in when ready. They can open a new terminal session or log out and back in to see the change take effect in their current session.

What shell does the new user get?

By default, adduser assigns bash, which is the most common shell in Ubuntu. If you want a different shell, you can change it later with sudo usermod -s /bin/zsh username, replacing /bin/zsh with the path to the shell you want.