How to create users in Linux, Centos 8, Redhat 8 (useradd command)
Last updated: Jan 31, 2022
In today's short article, I will tell you how to create and delete accounts in Linux. All of you sometimes encountered such a situation when you need to create or delete a user, and for this you turned to system administrators or tried to do something yourself. But in fact, everything is very simple. We look.
And so, before creating an account, first make sure that there is no such account. A list of all accounts can be found in /etc/passwd
To view, use the command:
$. cat /etc/passwd
As a result, we see a lot of unnecessary data from the lists of all accounts. To get only a list, use the command:
$. sed 's/:.*//' /etc/passwd
Now let's create a new account called oracle, for this we will use the command:
$. useradd oracle
After executing the command, the account should be successfully created, but the user will not be able to log into it. To be able to log in, you need to set a password for it. To set the newly created password account, use the command:
$. passwd oracle
The command will ask you to set a password for the oracle account and confirm the password, and after all, the account can be transferred to the user.
Now let's consider a situation where you need to delete an account and home directory and all files on the system. There is a command to delete an account:
$. userdel -r oracle
Everything, the oracle account has been deleted successfully.
Thank you all, I hope my article was of some help to you.