ubuntu add user

Ubuntu 20.04 Server – Users

- August 06, 2020

 

1.Ubuntu Server - useradd

In this lesson, we’ll look at useradd and how to add a new user with it.

useradd

useradd is a command that will work across Linux and BSD versions, so it’s more universal

than the adduser command we’ll look at in the next lesson.

To create a user with useradd, you have to specify several arguments upon creating the

account.

You’ll almost always want the user to have a home directory, based on his or her username,

commonly found in the /home directory.

The command to add a user here, is:

sudo useradd -d /home/dtrump -m dtrump

Looking in the /home directory, we can see that the sub-directory of dtrump was added.

Now, before Mr. Trump can log in, we have to add a password to the account.

As root, or with sudo, you can set the password for other peoples accounts.

The command to do this is passwd.

To do this, type:

sudo passwd dtrump

You’ll be prompted to enter your password, then confirm it.

Nothing will appear on the screen when you’re typing the password. This is normal.

If they match, you’re all set.

2.Ubuntu Server - adduser

 

Adduser

adduser is not in all distro’s. It is in Ubuntu and Debian. I’m not sure what other dirstro’s have

it, but in some distro’s it is simply a link to useradd.

In Ubuntu, it is a Perl script that, in the process of setting up a new user, calls on the useradd

binary.

It is a human readable file.

It does several steps for us in logical order, saving some typing, which is always a good thing.

3.Ubuntu Server – usermod

 

usermod

What if you have to modify a user after creation? usermod is made for that.

You can assign a user to an additional group, lock the account, unlock the account, move the

home directory, or set an expiration date for the account, to name just a few of the possibilities.

In this lesson, we look at how to add a user to the sudo group, giving the user sudo

permissions and how to lock and unlock a user account using usermod.