Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
The groupmod
command is a Linux command-line utility used to modify existing groups in the system. In this tutorial, we'll go over the basics of the groupmod
command and its usage.
The basic syntax for the groupmod
command is:
groupmod [options] group_name
Here are some common options used with the groupmod
command:
-g
: Change the Group ID (GID) of the group.-n
: Change the name of the group.-o
: Allow a non-unique GID (use with caution).Here are some examples to illustrate the usage of the groupmod
command:
sudo groupmod -g new_GID group_name
Replace new_GID
with the desired GID and group_name
with the name of the group you want to modify.
sudo groupmod -n new_group_name old_group_name
Replace new_group_name
with the new group name and old_group_name
with the existing group name.
sudo groupmod -g new_GID -o group_name
Replace new_GID
with the desired GID and group_name
with the name of the group you want to modify.
To verify that the group was modified successfully, you can check the /etc/group
file, which contains a list of all groups in the system:
grep 'group_name' /etc/group
Replace group_name
with the name of the modified group. The command output should show the updated group information.
In summary, the groupmod
command is a useful utility for modifying groups in Linux. It allows you to change the GID and name of existing groups. Make sure to run the command as root or with sudo
to have the necessary privileges.
How to use the groupmod
command in Linux:
groupmod
is a command-line utility in Linux used to modify user group properties.sudo groupmod options groupname
Modifying user groups with groupmod
:
groupmod
to modify various properties of an existing user group.sudo groupmod -g new_gid groupname
Changing group names in Linux using groupmod
:
-n
option with groupmod
.sudo groupmod -n newname oldname
Adding or removing users from groups with groupmod
:
groupmod
to add or remove users from a group with the -a
and -d
options, respectively.sudo groupmod -aG mygroup username # Add user to group sudo groupmod -g new_gid -d oldname # Remove user from group
Adjusting group properties using groupmod
:
-g
with groupmod
.sudo groupmod -g new_gid groupname
Renaming groups and updating group information:
-n
option in combination with other options.sudo groupmod -n newname -g new_gid oldname
Viewing current group settings before using groupmod
:
getent
command to view the current information about a group before making modifications.getent group groupname
Ensuring user permissions after group modifications:
groups
command to check a user's group memberships.groups username