How to Add a New User in Linux

How to Add a New User in Linux

In this Linux tutorial, we shall see how to add a new user to your system. If you're setting up a Linux machine for multiple users, or just want to create a new account for practice or development, this guide will walk you through it step by step.

Step 1: Open the Terminal

First things first, open your terminal. If you're on a server, make sure you're logged in as a user with sudo privileges.

Step 2: Use the useradd Command

To create a new user, we'll use the useradd command followed by the username you want to assign. For example, let's create a user named john:

sudo useradd john

But wait! This just creates the user—it doesn’t set a password or create a home directory. So let’s do that properly using options.

Step 3: Create User with Home Directory

Use the -m option to create the home directory automatically:

sudo useradd -m john

Step 4: Set a Password for the User

Now let’s give our new user a password. This is done using the passwd command:

sudo passwd john

You’ll be prompted to enter and confirm the new password:

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Step 5: Verify the User

To verify that the user was added successfully, you can check the list of users using:

cat /etc/passwd | grep john
john:x:1001:1001::/home/john:/bin/bash

This shows that the user john exists and has a home directory at /home/john.

Step 6: Optional – Add User to Sudoers Group

If you want your new user to have sudo (admin) privileges, add them to the sudo group:

sudo usermod -aG sudo john

Now john can use sudo to run admin commands.

And You're Done!

That’s it! 🎉 You’ve successfully added a new user to your Linux system. This is a foundational skill for Linux system administration. Practice this a few times, and you’ll be managing users like a pro.