How to change user groups for users in Linux

青灯夜游
Release: 2021-12-21 16:28:58
Original
20517 people have browsed it

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".

How to change user groups for users in Linux

#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 [选现] 组名
Copy after login

Options:

  • ##-g GID: Modify group ID;

  • -n New group name: Modify the group name;

Example:

[root@localhost ~]# groupmod -n testgrp group1
#把组名group1修改为testgrp
[root@localhost ~]# grep "testgrp" /etc/group
testgrp:x:502:
#注意GID还是502,但是组名已经改变
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!