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.
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:
The output should be:
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.
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:
The output should match this output:
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
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>
$ cat /etc/passwd | grep kgiii
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.
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.