Change gid of a specific group












28















I'd like to change group id of a specific group. There are so may solution for changing the gid of a file or directories. But that's not what I want. Is there a way to do that?










share|improve this question





























    28















    I'd like to change group id of a specific group. There are so may solution for changing the gid of a file or directories. But that's not what I want. Is there a way to do that?










    share|improve this question



























      28












      28








      28


      8






      I'd like to change group id of a specific group. There are so may solution for changing the gid of a file or directories. But that's not what I want. Is there a way to do that?










      share|improve this question
















      I'd like to change group id of a specific group. There are so may solution for changing the gid of a file or directories. But that's not what I want. Is there a way to do that?







      group






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 '12 at 13:20









      sr_

      13.1k3344




      13.1k3344










      asked Mar 9 '12 at 13:01









      mibzermibzer

      4522921




      4522921






















          3 Answers
          3






          active

          oldest

          votes


















          36














          The GID is the primary identifier of the group. As far as the system is concerned, a different GID is a different group. So to change the GID, you're going to have to modify all the places where that GID is used.



          You should avoid treating the GID as significant and use group names instead; you can change the name of a group with a single command (on Linux: groupmod -n NEW_GROUP_NAME OLD_GROUP_NAME).



          However, if you do really want to change the GID, this is how:




          • First, you may need to log out users in the group and kill processes who have that group as their effective, real or saved group.

          • Change the entry in the group database. On Linux, run groupmod -g NEWGID GROUPNAME. On other systems, use that system's administration tool, or vigr if available, or edit /etc/group as applicable.


          • Change the group of all the files on your system that belong to the old group.



            find / -gid OLDGID ! -type l -exec chgrp NEWGID {} ;


          • chgrp clears suid and sgid flags, restore those.


          • If you have any archive that uses the old GID, rebuild it.

          • If you have any configuration file or script that references the old GID, update it.

          • Restart all processes that must use the new GID.






          share|improve this answer





















          • 2





            Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

            – Mark Plotnick
            Jun 6 '14 at 21:44






          • 3





            groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

            – Matt
            Nov 19 '14 at 15:41



















          29














          The easiest way is to use groupmod -g <NEW_GID> <groupname>



          Another way is to edit /etc/group directly. The third field in each column is the gid.



          If the changed group is the main group of a user, /etc/passwd need to be adapted, too: usermod -g <NEW_GID> <username>.






          share|improve this answer


























          • Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

            – mibzer
            Mar 9 '12 at 13:12






          • 1





            No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

            – jofel
            Mar 9 '12 at 13:18











          • Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

            – mibzer
            Mar 9 '12 at 13:21













          • I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

            – jofel
            Mar 9 '12 at 13:25



















          0














          find /path -group foo -print0 | xargs -0 chgrp bar






          share|improve this answer
























          • as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

            – mibzer
            Mar 9 '12 at 13:11











          • ok, i was confused, then 'vi /etc/group' :)

            – jirib
            Mar 9 '12 at 13:13











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f33844%2fchange-gid-of-a-specific-group%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          36














          The GID is the primary identifier of the group. As far as the system is concerned, a different GID is a different group. So to change the GID, you're going to have to modify all the places where that GID is used.



          You should avoid treating the GID as significant and use group names instead; you can change the name of a group with a single command (on Linux: groupmod -n NEW_GROUP_NAME OLD_GROUP_NAME).



          However, if you do really want to change the GID, this is how:




          • First, you may need to log out users in the group and kill processes who have that group as their effective, real or saved group.

          • Change the entry in the group database. On Linux, run groupmod -g NEWGID GROUPNAME. On other systems, use that system's administration tool, or vigr if available, or edit /etc/group as applicable.


          • Change the group of all the files on your system that belong to the old group.



            find / -gid OLDGID ! -type l -exec chgrp NEWGID {} ;


          • chgrp clears suid and sgid flags, restore those.


          • If you have any archive that uses the old GID, rebuild it.

          • If you have any configuration file or script that references the old GID, update it.

          • Restart all processes that must use the new GID.






          share|improve this answer





















          • 2





            Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

            – Mark Plotnick
            Jun 6 '14 at 21:44






          • 3





            groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

            – Matt
            Nov 19 '14 at 15:41
















          36














          The GID is the primary identifier of the group. As far as the system is concerned, a different GID is a different group. So to change the GID, you're going to have to modify all the places where that GID is used.



          You should avoid treating the GID as significant and use group names instead; you can change the name of a group with a single command (on Linux: groupmod -n NEW_GROUP_NAME OLD_GROUP_NAME).



          However, if you do really want to change the GID, this is how:




          • First, you may need to log out users in the group and kill processes who have that group as their effective, real or saved group.

          • Change the entry in the group database. On Linux, run groupmod -g NEWGID GROUPNAME. On other systems, use that system's administration tool, or vigr if available, or edit /etc/group as applicable.


          • Change the group of all the files on your system that belong to the old group.



            find / -gid OLDGID ! -type l -exec chgrp NEWGID {} ;


          • chgrp clears suid and sgid flags, restore those.


          • If you have any archive that uses the old GID, rebuild it.

          • If you have any configuration file or script that references the old GID, update it.

          • Restart all processes that must use the new GID.






          share|improve this answer





















          • 2





            Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

            – Mark Plotnick
            Jun 6 '14 at 21:44






          • 3





            groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

            – Matt
            Nov 19 '14 at 15:41














          36












          36








          36







          The GID is the primary identifier of the group. As far as the system is concerned, a different GID is a different group. So to change the GID, you're going to have to modify all the places where that GID is used.



          You should avoid treating the GID as significant and use group names instead; you can change the name of a group with a single command (on Linux: groupmod -n NEW_GROUP_NAME OLD_GROUP_NAME).



          However, if you do really want to change the GID, this is how:




          • First, you may need to log out users in the group and kill processes who have that group as their effective, real or saved group.

          • Change the entry in the group database. On Linux, run groupmod -g NEWGID GROUPNAME. On other systems, use that system's administration tool, or vigr if available, or edit /etc/group as applicable.


          • Change the group of all the files on your system that belong to the old group.



            find / -gid OLDGID ! -type l -exec chgrp NEWGID {} ;


          • chgrp clears suid and sgid flags, restore those.


          • If you have any archive that uses the old GID, rebuild it.

          • If you have any configuration file or script that references the old GID, update it.

          • Restart all processes that must use the new GID.






          share|improve this answer















          The GID is the primary identifier of the group. As far as the system is concerned, a different GID is a different group. So to change the GID, you're going to have to modify all the places where that GID is used.



          You should avoid treating the GID as significant and use group names instead; you can change the name of a group with a single command (on Linux: groupmod -n NEW_GROUP_NAME OLD_GROUP_NAME).



          However, if you do really want to change the GID, this is how:




          • First, you may need to log out users in the group and kill processes who have that group as their effective, real or saved group.

          • Change the entry in the group database. On Linux, run groupmod -g NEWGID GROUPNAME. On other systems, use that system's administration tool, or vigr if available, or edit /etc/group as applicable.


          • Change the group of all the files on your system that belong to the old group.



            find / -gid OLDGID ! -type l -exec chgrp NEWGID {} ;


          • chgrp clears suid and sgid flags, restore those.


          • If you have any archive that uses the old GID, rebuild it.

          • If you have any configuration file or script that references the old GID, update it.

          • Restart all processes that must use the new GID.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 26 '16 at 13:32









          oakymax

          1034




          1034










          answered Mar 9 '12 at 21:20









          GillesGilles

          538k12810881606




          538k12810881606








          • 2





            Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

            – Mark Plotnick
            Jun 6 '14 at 21:44






          • 3





            groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

            – Matt
            Nov 19 '14 at 15:41














          • 2





            Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

            – Mark Plotnick
            Jun 6 '14 at 21:44






          • 3





            groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

            – Matt
            Nov 19 '14 at 15:41








          2




          2





          Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

          – Mark Plotnick
          Jun 6 '14 at 21:44





          Suggest using chgrp -h ... instead of chgrp .... Without -h, the target of any relevant symlink will have its group changed.

          – Mark Plotnick
          Jun 6 '14 at 21:44




          3




          3





          groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

          – Matt
          Nov 19 '14 at 15:41





          groupmod take's a name as the main argument for me... groupmod -g NEWGID GROUPNAME

          – Matt
          Nov 19 '14 at 15:41













          29














          The easiest way is to use groupmod -g <NEW_GID> <groupname>



          Another way is to edit /etc/group directly. The third field in each column is the gid.



          If the changed group is the main group of a user, /etc/passwd need to be adapted, too: usermod -g <NEW_GID> <username>.






          share|improve this answer


























          • Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

            – mibzer
            Mar 9 '12 at 13:12






          • 1





            No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

            – jofel
            Mar 9 '12 at 13:18











          • Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

            – mibzer
            Mar 9 '12 at 13:21













          • I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

            – jofel
            Mar 9 '12 at 13:25
















          29














          The easiest way is to use groupmod -g <NEW_GID> <groupname>



          Another way is to edit /etc/group directly. The third field in each column is the gid.



          If the changed group is the main group of a user, /etc/passwd need to be adapted, too: usermod -g <NEW_GID> <username>.






          share|improve this answer


























          • Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

            – mibzer
            Mar 9 '12 at 13:12






          • 1





            No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

            – jofel
            Mar 9 '12 at 13:18











          • Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

            – mibzer
            Mar 9 '12 at 13:21













          • I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

            – jofel
            Mar 9 '12 at 13:25














          29












          29








          29







          The easiest way is to use groupmod -g <NEW_GID> <groupname>



          Another way is to edit /etc/group directly. The third field in each column is the gid.



          If the changed group is the main group of a user, /etc/passwd need to be adapted, too: usermod -g <NEW_GID> <username>.






          share|improve this answer















          The easiest way is to use groupmod -g <NEW_GID> <groupname>



          Another way is to edit /etc/group directly. The third field in each column is the gid.



          If the changed group is the main group of a user, /etc/passwd need to be adapted, too: usermod -g <NEW_GID> <username>.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 9 at 0:38









          mgarey

          1034




          1034










          answered Mar 9 '12 at 13:09









          jofeljofel

          20.5k34980




          20.5k34980













          • Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

            – mibzer
            Mar 9 '12 at 13:12






          • 1





            No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

            – jofel
            Mar 9 '12 at 13:18











          • Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

            – mibzer
            Mar 9 '12 at 13:21













          • I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

            – jofel
            Mar 9 '12 at 13:25



















          • Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

            – mibzer
            Mar 9 '12 at 13:12






          • 1





            No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

            – jofel
            Mar 9 '12 at 13:18











          • Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

            – mibzer
            Mar 9 '12 at 13:21













          • I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

            – jofel
            Mar 9 '12 at 13:25

















          Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

          – mibzer
          Mar 9 '12 at 13:12





          Will this also effect gid of files too ? I mean, gid of file and gid of group will change at same time ?

          – mibzer
          Mar 9 '12 at 13:12




          1




          1





          No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

          – jofel
          Mar 9 '12 at 13:18





          No. This will change only the id of the group. Files/Directories keeps their (now unnamed) gid and need to be changed separately.

          – jofel
          Mar 9 '12 at 13:18













          Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

          – mibzer
          Mar 9 '12 at 13:21







          Ok thank you. So if I'd like to change their(files) gid to new gid, I have to execute another command. Is that right ? That would be better if there is way to change both gid of froup file and gid of related files at the same time.

          – mibzer
          Mar 9 '12 at 13:21















          I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

          – jofel
          Mar 9 '12 at 13:25





          I've added the other command to my answer. It is not a problem if temporary a gid is used which is not in /etc/group. Every user in the group has to re-login to have the new gid.

          – jofel
          Mar 9 '12 at 13:25











          0














          find /path -group foo -print0 | xargs -0 chgrp bar






          share|improve this answer
























          • as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

            – mibzer
            Mar 9 '12 at 13:11











          • ok, i was confused, then 'vi /etc/group' :)

            – jirib
            Mar 9 '12 at 13:13
















          0














          find /path -group foo -print0 | xargs -0 chgrp bar






          share|improve this answer
























          • as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

            – mibzer
            Mar 9 '12 at 13:11











          • ok, i was confused, then 'vi /etc/group' :)

            – jirib
            Mar 9 '12 at 13:13














          0












          0








          0







          find /path -group foo -print0 | xargs -0 chgrp bar






          share|improve this answer













          find /path -group foo -print0 | xargs -0 chgrp bar







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 9 '12 at 13:08









          jiribjirib

          1,002712




          1,002712













          • as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

            – mibzer
            Mar 9 '12 at 13:11











          • ok, i was confused, then 'vi /etc/group' :)

            – jirib
            Mar 9 '12 at 13:13



















          • as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

            – mibzer
            Mar 9 '12 at 13:11











          • ok, i was confused, then 'vi /etc/group' :)

            – jirib
            Mar 9 '12 at 13:13

















          as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

          – mibzer
          Mar 9 '12 at 13:11





          as I said that will change the gid of files. But that is not what I mean. I want to change gid of a group not a file.

          – mibzer
          Mar 9 '12 at 13:11













          ok, i was confused, then 'vi /etc/group' :)

          – jirib
          Mar 9 '12 at 13:13





          ok, i was confused, then 'vi /etc/group' :)

          – jirib
          Mar 9 '12 at 13:13


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f33844%2fchange-gid-of-a-specific-group%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?