One, user, group management commands
Cat Etc/group View all Groups
CAT/ETC/PASSWD View All Users
Useradd Create a new user
USERADD–G Group name User name add to XXX Group
Userdel–r User name Delete user everything
Userdel user name Deletes the user, does not delete the user's folder
passwd user name creates password for user
passwd-d Username Delete User password can also log in
PASSWD-L Username Lock Account
Passwd-u User name Unlock Account
USERMOD–G Group name User name to another group
Usermod–d Directory name User name change user Login initial directory
Usermod-l new username old username name for user renamed
Usermod-l to lock user name lock User Login
Usermod–u unlock user name unlock user login
Usermod–u 501 username change user uid
Groupadd to create a new group
Ls–ahl file name View all groups of files
CHGRP Group name File name modify the group where the file/folder is located
chmod 777 Xiaohua Modify Permissions
Groupmod–n new username old username name Group renamed
GROUPMOD–G 501 Group name change Group GID
Groupdel Group name Delete Group
GPASSWD-A User name Group name to add user to group
ID User name Check user information
-rw-r-r-
Permissions are divided into three types: R readable (4); W writable (2); x executable (1 indicates)
-File type-Represents a normal file, D represents a folder
The owner of the RW file has permission to the file, and RW says it can read and write
R permissions for the file in the group
R Permissions for users of other groups on this file
Second, the user group is the group of users. The Linux interior is represented by a GID.
Permissions are divided into read, write, execute three kinds of permissions.
The Linux user information is stored in the/etc/passwd file, and the/etc/shadow file holds the user password-related information.
/ETC/PASSWD file Format:
Username: Password: uid:gid: User information: Home directory path: User shell
Where the UID is 0 is the user root,1~499 for the system user, more than 500 for ordinary users
/etc/shadow Save user password information, including encrypted password, password expiration time, password expiration days, and so on.
The user group information is saved in the/etc/group file.
The format is as follows:
User group name: group Password: GID: Group account number (multiple accounts separated by commas)
After the user logs in, the GID in the/etc/passwd file is the user's initial user group.
The fact that the user's initial user group is not reflected in the/etc/group.
To view the user Group command for the current user:
[Root@local opt] #groups
Root bin daemon Sys adm disk wheel
In the output information, the first user group is a valid user group for the current user (current user group)
Toggle Valid User Group command 111CN. Net:
[root@local opt] #newgrp user group name
To leave the new valid user group, enter exit carriage return.
New User command:
[root@local opt] #useradd user name-G initial user group-G Other User group (modify/etc/group)-C User Description--Specify UID
The user needs to set a password for the user:
[root@local opt] #passwd user name
User to modify their password command:
[Root@local opt] #passwd
To modify user information commands:
[root@local opt] #usermod parameter user name
Parameters:
-C Description
-G Group name Initial user group
-E Expiration date format: YYYY-MM-DD
-G group name other user groups
-L Modify User name
-L Lock account (with two exclamation mark (!!) in front of the user's password string in the/etc/shadow file) )
-U unlock
To delete a user command:
[root@local opt] #userdel [-r] User name
where the parameter-R deletes the user's home directory.
In fact, there may be other parts of the system also have the user file, to complete the deletion of a user and its files to first find the file belongs to him:
[root@local opt] #find/-user user name
Then delete, and then run Userdel to delete the user.
To view the available shell commands:
[root@local opt] #chsh-l
To modify your own shell command:
[root@local opt] #chsh-s
View yourself or someone uid/gid information:
[root@local opt] #id [user name]
Groups is a valid user group in the return information
New User Group command:
[root@local opt] #groupadd user group name
To modify a user group name command:
[root@local opt] #groupmod-n Name
To delete a user group command:
[root@local opt] #groupdel user group name
To set the user group Password command:
[root@local opt] #gpasswd user group name
If gpasswd plus parameters there are other features
To set the user Group Administrator command:
[root@local opt] #gpasswd-a user name user group name
Add an account to group command:
[root@local opt] #gpasswd-m user name user group name
To remove an account command from a group:
[root@local opt] #gpasswd-d user name user group name
passwd Related parameter operation:
-L Lock User
-U Unlock User
-N days password cannot be changed
-X days Password expiration days
-W Days Warning days