Creating a username in Linux requires the useradd or adduser command, run from an account with administrator (root) permissions
The simplest way to create a new username is to open a terminal and use useradd or adduser, depending on which Linux distribution you have. The difference matters: useradd is the low-level tool available on nearly every Linux system, while adduser is a friendlier wrapper that asks you questions instead of requiring you to remember flags. Both do the same job, but adduser walks you through the process step by step.
You must have root access to create a new user account. If you are not logged in as root, you can run the command with sudo at the front — for example, sudo adduser newusername — and the system will ask for your password before proceeding.
Key Takeaways
- Use sudo adduser newusername on Ubuntu, Debian, and similar systems; it prompts you for password and user details instead of requiring command flags.
- Use sudo useradd -m newusername on Red Hat, CentOS, Fedora, and other systems that do not include adduser by default; the -m flag creates a home directory.
- The system will ask you to set a password when ready after creating the account, and you should choose something you can remember but others cannot guess.
- The new user can log in as soon as the account is created; you do not need to restart the computer or perform any additional steps.
Using adduser on Ubuntu and Debian systems
If you are on Ubuntu, Linux Mint, Debian, or another Debian-based distribution, adduser is the easiest path. Open a terminal and type sudo adduser newusername, replacing "newusername" with the actual name you want to create. The system will prompt you for your own password first (to confirm you have permission to create accounts), then ask you to set a password for the new user.
After the password, adduser will ask for the user's full name, room number, work phone, home phone, and other information. You can leave all of these blank by pressing Enter — only the password is required. Once you press Enter through all the prompts, the account is created and ready to use.
Using useradd on Red Hat, CentOS, and Fedora systems
On Red Hat, CentOS, Fedora, and other systems that do not include adduser, use useradd instead. The command is sudo useradd -m newusername. The -m flag is important — it creates a home directory for the user, which most accounts need. Without it, the user will have nowhere to store files.
After running this command, you must set a password separately by typing sudo passwd newusername. The system will ask you to enter the password twice to confirm it. Once both commands complete, the account is ready.
What happens when you create a username
When you create a new username, Linux does several things automatically. It assigns the user a unique ID number (called a UID), creates an entry in the system's user database (stored in /etc/passwd), and usually creates a home directory where that user can store files and settings. The home directory is typically located at /home/newusername.
The new user can log in when ready using the username and password you set. They can use the command line, run programs, and access files in their home directory. They cannot access files in other users' directories or make system-wide changes unless you give them special permissions later.
Setting a strong password during creation
When the system asks you to set a password, choose something that is at least 12 characters long and includes uppercase letters, lowercase letters, numbers, and symbols. Avoid words from the dictionary, your name, the username itself, or anything someone who knows you could guess. A password like Tr0pic@lSunset#2024 is stronger than password123 or newusername.
The person who will use this account should change the password themselves as soon as they log in for the first time. You can tell them to run passwd at the command line, which will ask them for the current password and then let them set a new one. This ensures only they know their own password.
Checking that the username was created
To verify that a new username exists, open a terminal and type id newusername. The system will display the user ID, group ID, and group memberships. If the account was created successfully, you will see output like uid=1001(newusername) gid=1001(newusername) groups=1001(newusername).
You can also check the file /etc/passwd by typing grep newusername /etc/passwd. This will show you the line that contains the new user's information. If nothing appears, the account does not exist or the username was spelled differently than you thought.
Common mistakes when creating usernames
The most common mistake is forgetting the -m flag when using useradd on Red Hat or CentOS systems. Without it, the user's home directory is not created, and they may have trouble logging in or storing files. If you make this mistake, you can create the directory manually by typing sudo mkdir -p /home/newusername and then sudo chown newusername:newusername /home/newusername.
Another mistake is using a username that already exists. Linux will refuse to create a duplicate and will tell you the user already exists. Check the existing usernames by typing cut -d: -f1 /etc/passwd, which lists every username on the system.
A third mistake is using uppercase letters or spaces in the username. Linux usernames should contain only lowercase letters, numbers, underscores, and hyphens. If you try to create a username with uppercase letters or spaces, the system will reject it or create the account with the characters converted to lowercase.
Frequently Asked Questions
Can I create a username without setting a password right away?
You can, but it is not recommended. If you use sudo useradd newusername without the -m flag and do not run sudo passwd newusername afterward, the account will exist but the user cannot log in. It is safer to set a temporary password during creation and let the user change it themselves on first login.
What if I want to create a username that cannot log in to the command line?
You can create an account with a disabled login by using sudo useradd -s /usr/sbin/nologin newusername. This is useful for system accounts that run services but should not allow human login. The account will still exist and can own files and processes.
How do I delete a username if I made a mistake?
Use sudo userdel -r newusername. The -r flag removes the user's home directory and all files in it. Without -r, the account is deleted but the home directory remains. Be careful — this cannot be undone.
Can I create a username with special characters like @ or #?
No. Linux usernames can contain only lowercase letters (a–z), numbers (0–9), underscores (_), and hyphens (-). They must start with a lowercase letter or underscore. If you try to use special characters, the system will reject the command.
What is the difference between a username and a UID?
A username is the human-readable name you type to log in, like "newusername". A UID is the number Linux actually uses internally to track the user, like 1001. You can have multiple usernames point to the same UID, but this is rare and usually a mistake. Most of the time, each username has its own unique UID.