View user names and groups on Linux and place specific users under specific groups

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.