- 1How to Add a New User in Linux
- 2Modify Existing User in Linux
- 3Delete a User in Linux — Step-by-Step for Beginners
- 4Create a User Group in Linux - Step-by-Step Tutorial
- 5Linux: Add User to Group
- 6How to Remove a User from a Group in Linux
- 7Delete a User Group in Linux - Beginner Friendly Tutorial
- 8Linux su Command Tutorial – Switch Users Easily
- 9Linux sudo Command - Execute as Another User
- 10Change a User's Password in Linux Using passwd
- 11Set Password Expiry in Linux using chage
- 12Lock a User Account in Linux
- 13How to Unlock a User Account in Linux
- 14Configure User Login Shell in Linux
- 15How to Configure User Environment Variables in Linux
- 16Edit .bashrc and .profile in Linux - User Startup Files Tutorial
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.
Next Topic ⮕Modify Existing User in Linux
Comments
Loading comments...