Manage Users and user groups in Linux and linux User Groups
Step 1: View users in Linux
All user files in the system are stored in/etc/paswd, which can be viewed by running the vim/etc/passwd command.
Step 2: view the user password and validity period File
You can run the vim/etc/shadow command to view the user password and the valid file/etc/shadow.
Step 3: view the group file of the account
The/etc/group file is the configuration file of the user group. The content includes the user and user group, and it can be displayed that the user belongs to the user group or several user groups, because a user can belong to one or more user groups, there are similarities between users of the same user group.
Step 4: view User Group passwords
You can run the vim/etc/gshadow command to view the files stored in the user group password. Each user occupies an exclusive row,
Step 5: Create and delete users
In CentOS, the main commands for creating and Deleting Users are as follows:
Useradd yhy create yhy user
Passwd yhy sets the password for the yhy user. The password is not displayed yet.
Useradd ybs-d/home/y create a ybs user and specify the home directory as/home/y.
Useradd user1-d/home/user1 do not add the-d parameter here because the default home directory of the user is in the same directory as the user in/home.
Useradd user2 add new user user2. The default home directory of the user is/home // user2
Userdel yhy deletes the user, but does not delete the Home Directory
Userdel-r ybs deletes the ybs user and does not delete the user's home directory.
Usermod-1 user2 user1 modify user1 name to user2
Usermod-L user1: Unlock user2. After locking, user2 cannot log on.
Usermod-U user2 unlock user user2
[Su-user1] the root user switches to a common user without a password.
The password is required for General su-root users to switch to the root user.
Step 6 create and manage user groups
In CentOS, the main commands for creating and managing user groups are as follows:
Groupadd grp1 create a new user group geoup1
Groupdel grp1 delete user group group1
Groupmod grp2 grp1 modify the user group name geoup1 to group2
Gpasswd-a user2 group2 Add User Group user2 to user group group2.
Gpasswd-d user2 group2 deletes user group user2 from user group group2.
Step 7: add several important commands
Who am I displays which user is currently logged on
W displays the details of the currently logged-on user, including the logon IP Address
Who displays brief information about the currently logged on user
Last displays the login times and duration of each user.
Finger searches for and displays user information. For example, finger zhangs indicates viewing zhangs user information.
Su user switches the user but does not switch the current directory
Ntsysv starts/disables services in the system.
Setup sets system running parameters.