Advance

Tutorial add and delete users on CentOS 8

Tutorial add and delete users on CentOS 8

One of your most common activities on a Linux server is to add or remove users. Today we present the tutorial add and delete users on CentOS 8. In this article, you will learn how to create user accounts, assign sudo privileges, and delete users on a CentOS 8 server.

 

Prerequisites

We consider that you are logged into a CentOS 8 server with a non-root sudo-enabled user, but you can drop the sudo portion of all the following commands if you are logged in as root instead. Because they would work either way.

Recommended Article: Find out list of all Open Ports in Linux

 

Tutorial add and delete users on CentOS 8

Adding Users

Add the new user by typing:

sudo adduser noodi

To give your user a password to let them log in, use the below command.

sudo passwd noodi

Now the new user is set up and ready to use, also you may be asked to type in the password twice to confirm it.

Granting Sudo Privileges to a User

In case you want to give the ability to execute commands with root (administrative) privileges to your user, you will need to give them access to sudo. To add your user to the wheel group, use the following command.

sudo usermod -aG wheel noodi

Then you will be asked to enter the password of your user account. After the correct password is submitted, the command you entered will be executed with root privileges.

 

Managing Users with Sudo Privileges

Although you can use the group to add and remove users with usermod, the command may not show which users are members of a group. when you need to see which users are part of the wheel group, you can use the lid command. And with the -g flag, you can reverse it and show which users belong in a group:

sudo lid -g wheel    Output
 centos(uid=1000)   noodi(uid=1001)

To verify that the previous commands were successful and the user has the privileges that they need, the output would show you the usernames and UIDs that are associated with the group.

 

Deleting Users

Delete all the user accounts that you have not used for a long time. To do this without deleting any of their files, use the below command.

sudo userdel noodi

But if you want to delete the user’s home directory along with their account, add the

-r flag to userdel:

sudo userdel -r noodi

 

Using the above commands, the user will be removed from any groups that they were added to. Including the wheel group while it is applicable. If you want to add another user with the same name, also add them to the wheel group again to gain sudo access.

 

in Conclusion, now you know, how to add and remove users from your CentOS 8 server. Try to separate users and give them only the access that is needed for them to do their job to face effective user management.

Dear user, we wish this tutorial add and delete users on CentOS 8would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day