CAT/ETC/PASSWD//View all user information
CAT/ETC/PASSWD|GREP User name//view information for a particular user
Cat/etc/group//View all group information
CAT/ETC/GROUP|GREP Group name//view information for a group name
Groups//view members of the currently logged in user group
Groups test//View the group that the test user is in, and the members in the group
WHOAMI//view current login user name
Find a group for newly added users
groupadd developers
Then create the user MX and add it to the developers user group:
useradd -G developers mx
To set a password for user mx:
passwd mx
Find a group for an existing user
Add an existing user MX to an existing user group Nginx, making this user an additional user group for that user, and you can use the directive with the-a parameter usermod
. -A represents append, which means that users are added to the new user group without having to leave the original other user group. However, you need to use the-G option with:
usermod -a -G nginx mx
If you want to change the MX primary user group to Nginx at the same time, use the-G option directly:
# usermod -g nginx mx
If you want to remove a user from a group,
gpasswd-d User Group
But this time you need to make sure that group is not the user's primary group.
View user names and groups on Linux and place specific users under specific groups