3. Linux adds a user (user) to a user group (group)

1. Change the password

If you are logged in as root, change the root password. Just enter

passwd
will appear:
New password: 
Retype new password: 
Enter the password to confirm as prompted.
If you want to change the password of another user, just enter passwd username.
For example: passwd lsyer
New password: 
Retype new password:
You can enter
passwd -- help

to see how to use this command.


2. Create a user group

# userdel sam
This command deletes the records of user sam in system files (mainly /etc/passwd, /etc/shadow, /etc/group, etc.), and deletes the user's home directory.

# useradd –d /usr/sam -m sam
This command creates a user sam,
where the -d and -m options are used to generate a home directory /usr/sam for the login name sam (/usr is the default user home directory where parent directory).

Code:
# groupadd group1

This command adds a new group group1 to the system. The group identification number of the new group is based on the current largest group identification number plus 1.

2. If you want to delete an existing user group, use the groupdel command, the format is as follows:

Code:
groupdel user group

3. Linux adds a user (user) to a user group (group)


usermod -a -G groupA user # Without -a will leave the original user group

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326174686&siteId=291194637