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