How to add users in Linux
A step-by-step guide to adding users, passwords, and user directories in Linux.
Wondering how to add users in Linux? There can be all kinds of reasons why you might need to add a new user to a Linux system. If you've got one of the best computers around, it makes sense that your family members might want to use it too.
The advantages of multiple user accounts include bolstering security, optimizing resource usage, and fostering collaboration. You can also improve safety by assigning specific permissions to users, minimizing the risks associated with widespread superuser access.
Collaboratively, multiple users can operate simultaneously in a multi-user environment, sharing resources without interference. Practical examples include creating an administrative user for system tasks, establishing individual developer accounts for project work, and setting up users for file sharing or team-specific accounts.
As with other operating systems like Windows 11 and macOS, adding new users in Linux is commonplace and easy. This how-to guide walks you through the basic first steps of setting up a new user in Linux.
How to add users in Linux
Note: Only administrative users can set up new user accounts, so you'll need to make sure you have sufficient access permissions on your system in order to carry out the steps below.
1. Open Command Line and enter "sudo useradd [username]"
To set up a new user in Linux, you will need to use the sudo command.
In Linux and other Unix-like operating systems, sudo stands for superuser do. It is a command-line utility that allows permitted users to execute a command as the superuser. Using "sudo" is a way to perform administrative tasks without logging in as the root user. (The root user has unrestricted access to all commands and files on a system, which can be potentially dangerous.)
Press Ctrl-Alt-T to open up your Linux command line interface. Now enter the sudo command in the following format: sudo useradd <username>
As you can see in the screenshot above, I ran the command sudo useradd David. I then needed to enter my password before the new user was added. You may not need to enter a password; it depends on how your system is configured.
2. Set a password for new user
For a user to have a workable login, they need a password. Enter sudo passwd [username]
I set up the new user's password with the command sudo passwd David.
You'll need to enter the password twice for security purposes. Once this has been done, Linux returns the message password updated successfully.
3. Check new user has been added by listing users
You can check that your new user has been added to the user list by entering the command cat /etc/passwd.
This produces a list of all users. It includes both applications and human users. The new user, David, now appears at the bottom of the list.
4. Set up a new user with a directory
It is also possible to create a new user and a user directory at the same time simply by adding -m to your useradd command.
In the example above, I ran the command sudo useradd -m Ncuti. This means that a user directory inside the home directory has been created for Ncuti.
5. Check home directory for new user
You can check the directory has been created by navigating to the home directory and typing ls.
In the example above, there are now two user directories in home. An existing directory called emma and a new one named Ncuti.
Once you have users set up in Linux, you can add details using the command usermod. Modifications might include adding the user's full name, changing their login shell, or adding them to groups. As with the useradd command, you'll need to have administrative permissions to make these changes.
Linux commands are incredibly versatile. This flexibility makes Linux a powerful tool when it comes to creating, modifying, and managing multiple user accounts.
Sign up to get the BEST of Tom's Guide direct to your inbox.
Here at Tom’s Guide our expert editors are committed to bringing you the best news, reviews and guides to help you stay informed and ahead of the curve!
Why not increase your Linux knowledge even further with our range of tutorials. We can show you how to rename a file in Linux, how to remove a directory in Linux and how to find a file in Linux.
Emma Street is a freelance content writer who contributes technology and finance articles to a range of websites, including Tom's Guide, Top10.com, and BestMoney. She has over 15 years of experience working in technical development within the fintech industry. When not writing about tech, Emma can be found writing romantic fiction, reviewing films, and updating her tea blog.