user group and password settings

/etc/passwd ⇒ user

/etc/group ⇒ group

/etc/shadow ⇒ password

 

Generally, the following sequence is used to create groups and users for the system

Create User -> Create Group -> Add User to Group -> Create Password

Example:
1. Create two groups
groupadd -g 6000 batch
groupadd -g 2018 tomcat
groupadd -g 22000 sabopeusr0
2. Create user
useradd -u 6000 -g 6000 -d /home/batch -s /bin/bash batch
useradd -u 2018 -g 2018 -d /opt/tomcat -s /sbin/nologin tomcat
useradd -u 22001 -g 22000 -d /home/sabopeusr0 -s /bin/bash sabopeusr0-admin
3. Add user to group
gpasswd -a batch tomcat
gpasswd -a tomcat batch
gpasswd -a sabopeusr0-admin wheel


4. Use chpasswd to add passwords in batches (note that if an error occurs again in the middle, it is best to execute it again)

First create a user password corresponding file, the format is username:password, such as abc:abc123, it must be written in this format,
and there can be no blank lines, save it as a text file user.txt, and then execute the chpasswd command:
chpasswd < user.txt


5. Modify a user's password
passwd sabopeusr001 individually

Guess you like

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