Managing users is a fundamental task in system administration, especially when working with Linux servers. Whether you're setting up a personal project or configuring a multi-user Ubuntu server, understanding how to create user accounts securely is essential. In this guide, we’ll walk you through everything you need to know about Ubuntu create user operations—from the command line basics to creating users with specific privileges and groups.
By the end of this tutorial, you’ll know how to:
-
Create a user in Ubuntu via command line.
-
Set up a user with sudo privileges.
-
Create a user with a home directory and password.
-
Add users to groups.
-
Use best practices when managing user accounts on your Ubuntu VPS.
Want to understand the basics first? Read our article What is Ubuntu before proceeding with user management.
Why You Need to Create New Users in Ubuntu
Using the root or default user account for everyday operations in Ubuntu is a security risk and a poor management practice. The root account has unrestricted access to the entire system, meaning any accidental or malicious command can cause serious damage. That's why it's strongly recommended to create a separate user with limited privileges, granting administrative access only when necessary using the sudo command.
Creating distinct user accounts also enhances accountability and organization, especially in collaborative environments like development teams, educational institutions, or hosted server applications. With individual user accounts, it's easier to monitor activity, restrict file access, and apply user-specific settings and permissions.
How to Create a User in Ubuntu
Let’s start with the most common way to create a new user in Ubuntu using the terminal.
Ubuntu Create User Command Line
To create a new user in Ubuntu via the terminal, use the adduser or useradd command.
sudo adduser newusername
-
This command creates a new user and sets up a home directory.
-
You'll be prompted to enter a password and some optional details.
This is the simplest form of ubuntu create user with home directory and ubuntu create user with password.
If you prefer more control, you can use:
sudo useradd -m -s /bin/bash newusername
sudo passwd newusername
This will:
-
-m: create the home directory manually.
-
-s: define the shell (Bash is the default).
-
passwd: prompt for setting the user password.
Want a broader overview? Check out our detailed guide on How to create users in Linux.
Ubuntu Create User with Sudo Privileges
How to Create a Sudo User in Ubuntu
After creating a user, you might want to give them admin privileges. This allows them to execute commands as root using sudo.
sudo usermod -aG sudo newusername
This command adds the user to the sudo group, effectively turning them into a Ubuntu admin user.
You can verify this with:
groups newusername
Need a deeper explanation of permissions? See our article on Add users to Sudoers.
Ubuntu Create User with Custom Settings
You might want to customize user creation based on your needs:
Ubuntu Create User and Group
You can create user Ubuntu along with a unique group:
sudo adduser newusername --ingroup customgroup
Or create a new group first and then assign it:
sudo groupadd developers
sudo useradd -m -G developers newdev
Ubuntu Create User with ID
If you want to assign a specific UID (user ID) and GID (group ID):
sudo useradd -u 1501 -g 1501 -m -s /bin/bash devuser
This is especially useful in enterprise systems or containers where user IDs must align.
Ubuntu Create User Without Password
In some scenarios, especially in automated systems or cloud environments, you may want to create a user account without setting a password. This is common when SSH key authentication is used instead of passwords or when third-party identity providers manage logins.
To create user Ubuntu without a password, run the following command:
sudo adduser newuser --disabled-password
This command creates the user and a home directory but disables the traditional password login mechanism. It’s a secure and flexible approach when you're planning to control access using more advanced methods like public key infrastructure (PKI), LDAP, or OAuth-based authentication services. Remember, even though the password is disabled, the user can still perform actions depending on their group memberships and permission levels.
Ubuntu Add User to Group
Adding a user to a group is a powerful way to assign permissions and organize access across services, directories, and system resources. Groups in Ubuntu are often used to manage access to specific software (like Docker), directories (like shared project folders), or functionalities (like administrative rights).
To add an existing user to a group, use:
sudo usermod -aG groupname username
For example, to give a user access to Docker without making them root:
sudo usermod -aG docker newusername
This ensures the user can run Docker commands without using sudo. After adding a user to a group, it’s often a good idea to log out and log back in for the changes to take effect.
To check a user’s group memberships:
groups username
Proper group management helps enforce the principle of least privilege and simplifies user administration. Explore our dedicated article on how to add users on Ubuntu for more group-related best practices.
Ubuntu List Users
Knowing how to list all user accounts on an Ubuntu system can help you manage access, monitor unauthorized logins, or simply audit user activity.
To display a list of users from the system’s user database, use:
cut -d: -f1 /etc/passwd
This command extracts the first field (username) from the /etc/passwd file, where all user accounts are registered.
Alternatively, for a more robust approach, try:
getent passwd
This pulls information from both local and remote (LDAP, NIS) sources, depending on system configuration.
For a quick and cleaner view of usernames only:
compgen -u
Each of these methods serves different purposes. Whether you're administering a personal VPS or overseeing a multi-user Ubuntu server, regularly reviewing your user list is a key part of maintaining system hygiene and security. For more detailed insights, check out our guide on how to list users in Ubuntu.
Ubuntu Create User in WSL
For Windows Subsystem for Linux (WSL), you can create a user using:
sudo adduser wsluser
To make this user the default for WSL:
ubuntu config --default-user wsluser
This makes the WSL experience closer to native Ubuntu behavior.
Ubuntu VPS Hosting: Take Control of Your Server
At 1Gbits Ubuntu VPS Hosting, you get full root access to your server. This allows you to:
-
Create and manage unlimited user accounts.
-
Grant admin access with fine-grained control.
-
Host websites, apps, or test environments.
-
Scale resources as your team grows.
Try our Ubuntu VPS today for reliable, secure, and powerful Linux hosting!
Final Thoughts
Creating and managing users in Ubuntu is essential for maintaining a secure, scalable, and well-organized system. Whether you're using an Ubuntu desktop, a server environment, or WSL, the process is nearly identical and straightforward when you follow best practices.
With this guide, you’ve learned how to:
-
Use command-line tools to create users.
-
Assign sudo privileges.
-
Add users to groups.
-
Work with Ubuntu server and WSL environments.
Ready to take full control of your Ubuntu experience? Explore our Ubuntu VPS Hosting solutions and start managing your own server environment today.
People also read: