how to manage users and groups (CentOS, Red Hat) on vultr vps

As the time it took me to add a user and create a group on CentOS from the console (I usually did it from the Admin Panel), if you search on the Internet statejki has one article (as always in order not to forget).

Use the useradd command to add a new user to an existing group. If the group does not exist, create it. Syntax:
useradd-d/home/user-G {group-name} username

Command-d specifies the home directory.

Create user vivek and add it to the Group of developers. Login as root and make sure that the Group of developers there are:

# grep-devel/etc/group

Conclusion:
devel: x: 84:

If there is no group, use command groupadd to create a new group of developers:

# groupadd devel

Then add the user to group devel vivek:

# useradd-G devel vivek

Set the password for user vivek:

# passwd vivek

Make sure that the user is added to the Group-devel:

# id vivek Output:
UID = 1122 (vivek) gid = 1125 (vivek) groups = 1125 (vivek), 84 (devel)

The-G option allows you to add a user to a group. You can list a comma-separated list of groups. For example, you will add user jerry in groups

Admins, ftp, www, devel, typing:

# useradd-G admins, ftp, www, devel jerry
Example of using useradd-Add a new user to primary group

To add a user group developers tony use following command:

# useradd-g devel tony

# id tony

UID = 1123 (tony) gid = 84 (devel) groups = 84 (devel)

The-g option allows you to add the user to the main group. The group must already exist.
Example of using usermod-Add an existing user to an existing group

Add an existing user to tony in a secondary group ftp:

# usermod-a-G ftp tony

Modify an existing user tony pervučnuû Group on the www:
# usermod-g www tony

Removing a user

userdel command [options] LOGIN

Some of the options:
-r remove a user’s login
-f prinudilel′noe the immediate removal of your account, even if the user is logged in at this momement, and destruction of its home and mail directories, even if they are used by other users.

Example

# userdel-r user