How to manage Linux user group

The Linux groupmod command

The name of the Linux group and the Linux Group ID number (GID) of the group can be changed with the groupmod command.

To change the GID of a Linux group, use the groupmod -g <gid> <groupname> command. To change the name of the Linux group, use the groupmod -n <newname> <groupname> command.


[[email protected] ~]# groupmod -n newgrname oldgrname

The Linux gpasswd command

The Linux gpasswd command also can be used for managing groups. gpasswd allows an administrator to configure group administrators, group members, and a group password. Group administrators can add and delete users as well as set, change, or remove the group password. A group can have more than one group administrator. Following are some of the options with gpasswd command.

• To add group administrators, use the gpasswd -A <users> <groupname> command, where <users> is a comma-separated list of existing users you want to be group administrators (without any spaces between commas).

• The root user or a group administrator can add users to the group with the gpasswd -a <user> <groupname> command.

• To remove a user from a group, use the gpasswd -d <user> <groupname> command.

• To add or change the password for a group, the root user or a group administrator can use the gpasswd <groupname> command. When changing the password, the old password is not needed.

• To remove the group password, use the gpasswd -r <groupname> command.

How to find the Linux group information using id command

To find the group information of a user, id command can be used.

[[email protected] ~]# id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)

How to remove Linux group using groupdel command

The command used for removing a Linux group is groupdel and the simple syntax for Linux groupdel command is groupdel <groupname>.


[[email protected] ~]# groupdel engineering

Related Tutorials
• Introduction to Linux user administration
• How to add a user in Linux using useradd command
• How to use passwd command to manage user passwords
• How to modify a Linux user using usermod command
• How to set Linux password aging using chage command
• How to remove user from Linux using userdel command
• The Linux user database (/etc/passwd)
• The Linux password database (/etc/shadow)
• Introduction to Linux User Group
• How to create a new group in Linux using groupadd command
• Linux Group Database (/etc/group) file