Create A New User In Linux

If you’re familiar with Linux, you’ll already know that Linux is a multiuser system and today we’ll learn how to create a new user in Linux. This shouldn’t be a very complicated article. In some more advanced operations, you may be required to create a new user. This article will be about that.

If you aren’t already aware, you have a whole lot of users on your Linux system. You have more users than just your user account and certain things can be done by certain users. You can generally use an elevated account (or sudo) to overcome those user restrictions.

There may come a time when you want to share your device with another person. So, there’s another reason to create an additional user. If you’re managing a server with multiple users, there’s another reason to create a new user in Linux. There are any number of reasons why you’d like to create a new user and we’ll go over that process today.

We’ll just be using a couple of tools today. It’s not complicated.

useradd:

The main tool we’ll be using is the useradd command. This is a tool that’s certainly installed by default on any major distro. It’s a part of the basic building blocks we use to manage Linux, so this doesn’t require any installation. You can verify that you have useradd available with the following command:

which useradd

The output should be:

/usr/sbin/useradd

If you check the man page, you’ll see this:

useradd – create a new user or update default new user information

So, as our goal is to create a new user, you can see that this is the correct tool for the job. I can’t think of a better tool for the job, as it should do everything behind the scenes as well.

passwd:

We’ll also be using the passwd command. This isn’t strictly necessary, but it’s in your best interest to set a user’s password. Once again, you won’t need to install anything and the following command will confirm that:

which passwd

The output should match this output:

/usr/bin/passwd

The text alone should let you know that this is a tool for setting passwords, but you can always refer to the man page to learn more. This is how passwd is described:

passwd – change user password

As I said, you don’t have to undergo this step but it’s in your best interests, from a security standpoint, to assign passwords to users who have any access to your system. And, as you can see, this is the right tool for the job of setting a user’s password.

Create A New User In Linux:

Of course, this is done in the terminal. As a general rule, you can press CTRL + ALT + T and your default terminal should open. That’s a fairly common shortcut that I mention often. You can also find a terminal in your application menu, pretty much regardless of which desktop environment you’re using and whichever Linux you’re using.

Creating The New User:

With your terminal now open, you’ll need to use elevated privileges, and the syntax is quite simple. To create a new user in Linux, the syntax follows:

sudo useradd <username>

This should be lowercase as Linux doesn’t like capital letters in usernames. So, for my username, the command would look like this:

sudo useradd kgiii

You can confirm that you’ve added the user with the following command:

cat /etc/passwd | grep <username>

For example:

$ cat /etc/passwd | grep kgiii
kgiii:x:1000:1000:kgiii,,,:/home/kgiii:/bin/bash

With your user firmly in place, you should set a password. Let’s do that next.

Set A Password For Your New User:

You’re almost always going to want a password for your new user. That’s easily done and also requires elevated permissions. You’ll need to continue using the terminal when you want to set a new password for the user.

The syntax for setting a password for your new user is as follows:

sudo passwd <username>

After you authenticate, the system will have you type in the password twice. It does this to ensure you’ve not made a mistake while typing, though it could be that you’ve made the same mistake twice.

So, be careful with this step. Otherwise, you have to find some way to reset the new user and the quickest way to do that would be to delete the user and start again.

Closure:

Yeah, I guess this counts as a short article. My most recent articles have been longer than this one. This one is about the length of my earliest articles, maybe slightly longer. The site has evolved!

Anyhow, you’ve learned how to create a new user in Linux. It shouldn’t matter which distro you’re using. The kernel you’re using shouldn’t impact this at all. It shouldn’t even matter what shell you’re using, this should simply work. If you want to create a new user, this is how you do it.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

View Comments

Recent Posts

Is Your Storage Drive An SSD Or An HDD?

Today's article aims to answer a simple question, simply is your storage drive an SSD…

2 days ago

Monitor System Resources With “Resources”

Today is one of those days when I'd like to introduce you to new software…

4 days ago

Short: The Halt Command

Today's article is intentionally short because we're simply going to learn about the basics of…

6 days ago

Installing Flatpaks In Linux

Today we're going to have a pretty easy article where you'll learn about installing Flatpaks…

1 week ago

A Quick Look At The Shutdown Command

This is going to be just a quick article about a command many of you…

1 week ago

Setting Up Coding Environments on Linux for Educational Use

With so many strong attributes, such as robustness and flexibility, Linux stands as a powerful…

2 weeks ago