Add and delete users on centOS 8; Through this tutorial, we will learn how to add and delete users on CentOS 8.
How to Add and Delete Users on CentOS 8
Just follow the following method’s to add and delete users on CentOS 8:
- How To Add User in CentOS 8
- How To Delete a User in CentOS 8
How To Add User in CentOS 8
The useradd command-line utility in CentOS can be used to establish a new user account.
We would run the following commands to create a new user account named “username”:
sudo adduser username
There is no output from the command above. It will construct the new user’s home directory (
/home/username) and copy files from the
/etc/skel directory to it. The user can write, edit, and delete files and folders in their home directory.
After that, we’ll need to provide the new user a password so that they may log in. Use the passwd command to do so:
sudo passwd username
We’ll be asked to type in and confirm password. Make sure password is strong.
Output Changing password for user username. New password: Retype new password: passwd: all authentication tokens updated successfully.
Sudo access is allowed to members of the group wheel by default on CentOS.
Add the newly created user to the wheel group if we want them to have administrative rights:
sudo usermod -aG wheel username
If we are logged in as root, we don’t have to prepend each command with sudo.
How To Delete a User in CentOS 8
We can delete the user account using the
deluser command-line utility if it is no longer required.
Run the following command to deactivate the user without removing the user’s files:
sudo userdel username
-r flag is used to destroy the user’s home directory and mail spool:
sudo userdel -r username
userdel command produces no output when it succeeds.
If the user has sudo capabilities, he or she will be removed from the wheel group, as well as any other groups to which the user belongs.
Add and delete users on centOS 8; Through this tutorial, we have learned how to add and delete users on CentOS 8.