1

Having trouble with this question. How can I take "myGroup" and make it have the same GID as a different group, such as sudo, with the GID 27? When I run the following command, Linux says that the GID already exists:

groupmod -g 27 myGroup
1

From man groupmod:

The value of GID must be a non-negative decimal integer. This value must be unique, unless the -o option is used.

So all you have to do is to add the -o-option to your command, you will also need root-privileges to run the command:

sudo groupmod -o -g 27 myGroup

I don't know why you want to do this and I can't tell you what the side-effects of doing so are. For me this sounds a bit scary, but you might have a good reason.

2
  • Thanks for the input. I'm currently learning the basic commands and one of the problems I've been given is to change a GID to be a duplicate of another. It's the only problem I'm having troubles completing. After trying this new command, Linux still isn't happy. I get this message: "groupmod: Permission denied. groupmod: cannot lock /etc/group; try again later." Do you know why this is occurring? – Jusitn Bittinger Sep 9 '19 at 4:39
  • @JusitnBittinger Of course, you will need root-privileges to run this command, see my edit – mook765 Sep 9 '19 at 4:44
0

The groupmod has to be used with the --non-unique command line option to allow for two groups with the same identifier.

You may also edit the /etc/group file manually.

A group entry look like this:

sudo:x:27:

The "x" is a password placeholder. Passwords are not going to ever appear in the /etc/group file anymore. Instead they are put in the shadow file.

The first field is the name and the 3rd the number.

The forth field (empty in the example above) is the list of comma separated user names of users in that group.

So for example you could add:

odus:x:27:henri

Note that using such doubly named groups can be tricky. Most software will most certainly not handle it correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.