Linux Study Notes - Part 8
Command:
groupadd:
command to add group
Format: groupadd [-g GID] groupname
Without -g, create a group according to the default gid of the system, and the gid also starts from 1000
groupdel
command to delete group
A group with a user cannot be deleted, the user must be deleted before the group can be deleted
useradd:
increase user
Format: useradd [-u UID] [-g GID] [-d HOME] [-M] [-s]
-u: Indicates custom UID
-g: Indicates that the newly added user belongs to an existing group, which can be followed by a group id or a group name
-d: Indicates the home directory of the custom user
-M: Indicates not to create a home directory
-s: indicates a custom shell
userdel:
delete users
Format: userdel [-r] username
-r: When deleting a user, delete the user's home directory
If a group is occupied by two accounts, it cannot be deleted
chfn:
Change the user's finger
passwd:
Set a password for the user
mkpasswd:
for generating random passwords
-l: set length
-s: specifies the number of special characters
-d: specifies the number of digits
whoami:
View current users
his:
switch user
Form: su [-] username
Adding "-" will initialize various environment variables of the current user
sudo:
It is a common user who temporarily has root privileges without knowing the root password, which improves security.