The Wayback Machine - https://web.archive.org/web/20240213201555/https://www.geeksforgeeks.org/groupmod-command-in-linux-with-examples/
Open In App
Related Articles

groupmod command in Linux with examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

groupmod command in Linux is used to modify or change the existing group on Linux system. It can be handled by superuser or root user. Basically, it modifies a group definition on the system by modifying the right entry in the database of the group. Syntax:

groupmod [option] GROUP

Files: The groupmod command has following files.

  • /etc/group: Group Account Information.
  • /etc/gshadow: Secured group account information.
  • /etc/login.def: Shadow passwd suite configuration.
  • /etc/passwd: User account information.

Exit Values:

  • 0: Success.
  • 2: Invalid command Syntax.
  • 3: Invalid argument to option.
  • 4: specified group doesn’t exist.
  • 6: specified group doesn’t exist.
  • 9: group name already in use.
  • 10: can’t update group file.

Options: There are following option available in groupmod command.

  • -g, –gid GID: The group ID of the given GROUP will be changed to GID.
  • -n, –new-name NEW_GROUP: The name of group will change into newname.
  • -h, –help: This option display help message and exist.
  • -o, –non-unique: This option used with the -g option that allow to change the group GID to a non-unique value.
  • -p, –password PASSWORD: This gives the encrypted password.
  • -R, –root CHROOT_DIR: Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.

Example: Below command will change the group group_old to group_new using -n option.

groupmod -n group_new group_old

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 15 Dec, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials