In this guide, we will explain how to add and remove a user on your Linux server. There are small differences in the different Linux distributions. With Red Hat based distributions you will not be prompted to enter a password. With Debian based distributions you will be prompted to enter a password. You are also prompted to enter personal data for the new user with Debian based systems.

Contents
1. Add a user
2. Add and remove a user from the sudo group
3. Remove a user

Add a user

In this example, we will create a new user called worldstream. We can create this user by using the following command:

[root@worldstream ~]# adduser worldstream

On a Red-Hat based system, you will not automatically be prompted for a password. In order to set the password you can use the following command:

[root@worldstream ~]# passwd worldstream

Add and remove a user from the sudo group

When you have created a new user you can also add the user to the sudo group. On Debian based systems this is done with the following command:

[root@worldstream ~]# usermod -aG sudo worldstream

If you are using a Red-Hat based system you can achieve the above with the following command:

[root@worldstream ~]# usermod -aG wheel worldstream

If you want to remove a user from the sudo group on a Debian based system you can use the following command:

[root@worldstream ~]# gpasswd -d worldstream sudo

In case you want to remove a user from the sudo group on a Red-Hat based system you can use the following command:

[root@worldstream ~]# gpasswd -d worldstream wheel

Remove a user

In order to remove a user the following command can be used:

[root@worldstream ~]# userdel worldstream

Do note with removing users this way that the home directory of the user will not be automatically removed. In case you also wish to remove the home directory of the user please use the -r option with the userdel command. This option will also remove the user’s mail spool. Below is an example of this command.

[root@worldstream ~]# userdel -r worldstream

Conclusion

In this guide, we have shown you some of the basics with user accounts.  Adding, modifying, and removing users can come in handy when you have just received your new server. This guide will provide some steps to get started with new users on your system. Keep in mind that some commands may vary with other Linux distributions.

If you are facing any difficulties with the user management on your server feel free to email us here.

Learn more about our services: worldstream.com