Today’s article is going to be quick and easy as we simply discuss how you create a new user. This is a fairly basic task and shouldn’t take too long to cover. If you want to create a new user, read on!
If it’s not obvious, you have a user account. You use this information even if you don’t realize it. Indeed, you use this information when you log into your computer to begin with. When you log in, you’re logging into your user account.
There are other users. You may have a root account or an account for MySQL. If you want to know how many different users are on your system, you can follow along with the following article:
How To: List All Users In Linux
One of the things that helps keep Linux secure is that it’s a true multi-user environment. You can only perform operations on the files you have access to. This is why you use sudo or root.
Managing users is a fundamental task in Linux. This article is going to cover how to create a new user and we’ll be doing so in the terminal. This should be fairly universal and you won’t need to install anything as user management tools will be included by default.
We will use a couple of tools, however. The first among them is:
The useradd command is basic and, as the name implies, is used to add new users. There’s nothing complicated about it in today’s article and you can be certain that this is already a tool available to you.
If you’re curious about the command, check the man page:
man useradd
If you do so, you’ll see that it’s described as this:
useradd – create a new user or update default new user information
So, that’s the correct tool for this job.
The other tool we’ll be using is the passwd command. You can again tell by the name what the tool is going to do. Simply, it’s used as a password management tool. This too isn’t all that complicated and you can check the man page with this command:
man passwd
If you do so, you’ll see that I wasn’t kidding and that this tool does what you think it does. It’s described like so:
passwd – change user password
This is the correct tool for the job. After we create a new user, we’ll assign them a password. If the user wishes, they can change that password on their own.
As mentioned above, we’ll create a new user with terminal-based tools. This is a nice and universal way to do things. Sure, there are GUI tools out there but this is going to work on any Linux system you’re likely to engage with. You can crack open your favorite terminal, often by just pressing CTRL + ALT + T on your keyboard.
First, we’ll create a new user with the useradd command. The syntax is very simple:
sudo useradd <new_username>
For example:
sudo useradd peter
Now, we’ll add a password. This is also a simple command:
sudo passwd <new_username>
For example:
sudo passwd peter
You’ll be asked to enter the password a couple of times. This is to help ensure that you’ve not made any typographical errors while entering the password. It’s all basic stuff.
Next, you can verify that the new user account has been created. For this next step, we’ll simply use cat and grep.
cat /etc/passwd | grep <new_username>
Again, here’s an example:
cat /etc/passwd | grep peter
The output should look a little something like this:
$ cat /etc/passwd | grep peter peter:x:1000:1000:peter:/home/peter:/bin/bash
If you find your user, you’ve done this properly and you’ve learned how to create a new user. I told you that it wouldn’t be too complicated!
So… This is an article about how to create a new user. It’s a pretty basic task but one you might just want to know about. You never know when you’ll need to create a new user but now you know where to look if you do need to. User management can be a pretty important task, especially for a server admin.
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.
Today we'll cover one way to enable or disable your network interface in the Linux…
Today's exercise is a nice and simple exercise where we check your NIC speed in…
Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…
I think I've covered this before with the ls command but this time we'll count…
Today we'll be learning about a basic Linux command that's known as 'uname' and it…
If you've used hardinfo in the past, it may interest you to know that hardinfo…