Adding and removing users
Useradd-u Custom Uid-g Custom gid-d Specify home directory-m do not build home directory-S custom shell
such as: #useradd-u 508-g 500-d/home/user3/-s/bin/nologin user2
#tail-2/etc/passwd
User2:x:508:500::/home/user3/:/bin/nologin
By adding a user to a group, the group cannot be deleted, and the group that owns the user needs to be modified before it can be deleted
Userdel-r Username Delete a user
Delete User's time, do not add-R then delete the user's directory afterwards, can only manually
Rm-rf/home/username/var/spool/mail/username
such as: Userdel-r User3
Userdel:/home/user3 does not belong to User3, so it does not delete
[Email protected] ~]# Rm-rf/home/user3/var/spool/mail/user3
Usermod Modifying user Properties
-U uid-g gid-d Change home directory-S change user shell-g change extension group-l lock User (cannot log on)-U unlock
If the user's extension group is within group, then the group can be deleted.
such as [[email protected] ~] #id aming123
uid=501 (aming123) gid=513 (aming123) group =513 (aming123)
[[email protected] ~]# ID User3
uid=506 (User3) gid=502 (GRP1) group =502 (GRP1), (GRP2)
[Email protected] ~]# Groupdel GRP2
[[email protected] ~]# ID User3
uid=506 (User3) gid=502 (GRP1) group =502 (GRP1)
passwd Modifying user passwords
Change the current user password after passwd not with the user name
MKPASSWD automatically generate passwords
Mkpasswd-l n Specifies a length of n
-S n specifies a special character n
-D n Specifies the number of n
-c n Specifies a lowercase n
-c n specifies an uppercase letter N
#passwd--stdin username to enter the plaintext password for username The shell implementation is required to set the password for the user
If you give: aming123 set the password
#echo "aminglinux.com" |passwd--stdin aming123
Change the password for the user aming123.
PASSWD: All the authentication tokens have been successfully updated.
If no user name is given, the password is changed to root by default
Linux notes ... File and Directory Properties Useradd, Userdel, Usermod, passwd