How to Add and Remove Users

How to Add and Remove Users

How to Add a User

If you are signed in as the root user, you can create a new user at any time by typing:

adduser newuser

If you are signed in as a non-root user who has been given sudo privileges, as demonstrated in the initial server setup guide, you can add a new user by typing:

sudo adduser newuser

You will then be asked to setup a password for the new user.

Next, enter any additional information about the new user. This is entirely optional and can be skipped by hitting Enter if you don't wish to utilize these fields.

Finally, you will be asked to confirm that the information you provided was correct. Enter Y to continue.

Your new user is now setup and ready for use! You can now log in using the password you set up.

 

How To Delete a User

In the event that you no longer need a user, it is best to delete the old account.

You can delete the user itself, without deleting any of their files, by typing this as root:

deluser newuser

If, instead, you want to delete the user's home directory when the user is deleted, you can issue the following command as root:

deluser --remove-home newuser