Home > Article > Operation and Maintenance > How to change user groups for users in Linux
In Linux, you can use the groupmod command to change the user group for the user. The function of this command is to modify the relevant information of the user group. It can be used to change the group (user group) identification code or name; the syntax is " groupmod -n new group name group name".
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
In Linux, you can use the groupmod command to change user groups for users.
The groupmod command is used to modify the relevant information of the user group, and can change the group (user group) identification code or name.
The command format is as follows:
[root@localhost ~]# groupmod [选现] 组名
Options:
##-g GID: Modify group ID;
-n New group name: Modify the group name;
[root@localhost ~]# groupmod -n testgrp group1 #把组名group1修改为testgrp [root@localhost ~]# grep "testgrp" /etc/group testgrp:x:502: #注意GID还是502,但是组名已经改变But everyone still Be careful not to modify the user name at will, nor the group name and GID, because it is very easy to cause confusion in the administrator's logic. If you must modify the user name or group name, it is recommended that you delete the old one first and then create a new one. Related recommendations: "
Linux Video Tutorial"
The above is the detailed content of How to change user groups for users in Linux. For more information, please follow other related articles on the PHP Chinese website!