Skip to content

Creating Users#

The command to add a user to your Ubuntu system is adduser. I don't need to go into details on how-to use this command because you can read the manpage now, right?

Let's look at some examples:

1
sudo adduser superman

Then we get this:

1
2
3
4
5
6
michael@develop:~$ sudo adduser superman
Adding user `superman' ...
Adding new group `superman' (1001) ...
Adding new user `superman' (1001) with group `superman' ...
The home directory `/home/superman' already exists.  Not copying from `/etc/skel'.
New password:

Instead of providing most of the information along with our command line, we're prompted for the information needed by the command. I'm going to fill it out like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
michael@develop:~$ sudo adduser superman
Adding user `superman' ...
Adding new group `superman' (1001) ...
Adding new user `superman' (1001) with group `superman' ...
The home directory `/home/superman' already exists.  Not copying from `/etc/skel'.
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for superman
Enter the new value, or press ENTER for the default
        Full Name []: Superman
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]

For the password I just used badpassword because to be honest it doesn't matter inside of our VM.

We can also provide all the answers to these question on the command line too, except for the password:

Note

Use sudo deluser superman to delete the user before you try the below command, otherwise it won't work.

1
sudo adduser superman --gecos "Superman,,,,"

And we get this:

1
2
3
4
5
6
7
8
michael@develop:~$ sudo adduser superman --gecos "Superman,,,,"
Adding user `superman' ...
Adding new group `superman' (1001) ...
Adding new user `superman' (1001) with group `superman' ...
The home directory `/home/superman' already exists.  Not copying from `/etc/skel'.
New password:
Retype new password:
passwd: password updated successfully

Now we have a user called superman on the system. We can login as that user now. Try it:

  1. Logout of your current user by typing exit
  2. At the login prompt login with superman and badpassword (unless you picked a different password)

And just like you're the superman user.

That's the simple way of creating users. In an enterprise or business environment, user management could be centralised, and this isn't how you would add users. It depends and changes from environment to environment.

As the superman user, give this a try: sudo adduser spiderman. I get this:

1
2
3
superman@develop:~$ sudo adduser spiderman
[sudo] password for superman:
superman is not in the sudoers file.  This incident will be reported.

It failed because our first user, in my case michael, has been granted access to the sudo command and can run privileged commands. Our new user, superman, cannot. Let's fix that.