How to add a user to a user group in Linux

Source: Internet
Author: User

In Linux, how does one add a user to a user group? How does one add a user to a user group in Linux? When using a common method to create a user, such as the Shell code # useradd testuser1 created by testuser1, the group in which the user is located, and supplementary group contain only one group with the same name as the user name. to add user testuser1 to another existing group, you must set supplementary group of user testuser1. first, check the current situation of testuser1: Shell code # id testuser1 www.2cto.com. This will get the output similar to the following: Shell code uid = 502 (testuser1) gid = 502 (testuser1) groups = 502 (testuser1) You can also use the following command: Shell code # groups testuser1. This will get the output similar to the following: Shell code testuser1: testuser1. In fact, the role of the command groups is equivalent: shell code id-Gn www.2cto.com now, assume that another group exists in the system and its name is testgroup1. Run the following command to include the supplementary group of testuser1: shell code # usermod-a-G testgroup1 now check the situation of testuser1 again, you will get the output similar to the following: Shell code uid = 502 (testuser1) gid = 502 (testuser1) groups = 502 (testuser1), 501 (testgroup1). Of course, the group id 501 here is also a demonstration. note that for the above command usermod, you need to add the option '-A', which indicates the append operation. if you only have the option '-G', You need to list all supplementary groups in the parameters following it. author xwv

Related Article

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.