How to list groups with gid in redhat?











up vote
33
down vote

favorite
9












I first listed the groups using :



groups 


I added group using



groupadd -g 300 oinstall
groupadd –g 500 dba


and then when I do



groups 
root bin daemon sys adm disk wheel sfcb


I am unable to find groups I added. How to list groups with group id?
Also, if I try to add it again it says groups is already present.










share|improve this question


























    up vote
    33
    down vote

    favorite
    9












    I first listed the groups using :



    groups 


    I added group using



    groupadd -g 300 oinstall
    groupadd –g 500 dba


    and then when I do



    groups 
    root bin daemon sys adm disk wheel sfcb


    I am unable to find groups I added. How to list groups with group id?
    Also, if I try to add it again it says groups is already present.










    share|improve this question
























      up vote
      33
      down vote

      favorite
      9









      up vote
      33
      down vote

      favorite
      9






      9





      I first listed the groups using :



      groups 


      I added group using



      groupadd -g 300 oinstall
      groupadd –g 500 dba


      and then when I do



      groups 
      root bin daemon sys adm disk wheel sfcb


      I am unable to find groups I added. How to list groups with group id?
      Also, if I try to add it again it says groups is already present.










      share|improve this question













      I first listed the groups using :



      groups 


      I added group using



      groupadd -g 300 oinstall
      groupadd –g 500 dba


      and then when I do



      groups 
      root bin daemon sys adm disk wheel sfcb


      I am unable to find groups I added. How to list groups with group id?
      Also, if I try to add it again it says groups is already present.







      rhel command






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 26 '13 at 2:51









      kinkajou

      2851411




      2851411






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          57
          down vote



          accepted










          The groups command lists groups that the user is currently a member of, not all the groups available on the system. You can lookup a group by name or gid using the getent command.



          getent group oinstall
          getent group 500


          To show all the groups, just leave your search query off of the command:



          getent group





          share|improve this answer



















          • 2




            @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
            – jordanm
            Oct 26 '13 at 3:02






          • 1




            @kitex I updated to wording slightly, hope that helps you understand.
            – jordanm
            Oct 26 '13 at 3:21






          • 2




            @Kitex updated the answer
            – jordanm
            Oct 26 '13 at 16:22






          • 2




            @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
            – jordanm
            Feb 1 '16 at 20:10






          • 1




            @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
            – ctrl-alt-delor
            Nov 22 at 13:35


















          up vote
          8
          down vote













          You can list groups by using getent



          When running the command, the GID is the third value in the output, e.g:



          $ getent group
          man:x:15:
          audio:x:63:
          nobody:x:99:
          users:x:100:
          <--snipped-->
          utmp:x:22:


          So to only list groupnames and their GID, use awk to print the columns you want like this:



          $ getent group | awk -F ":" '{ print $1,$3 }'
          man 15
          audio 63
          nobody 99
          users 100
          utmp 22


          See also http://man7.org/linux/man-pages/man1/getent.1.html






          share|improve this answer



















          • 6




            Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
            – jordanm
            Oct 26 '13 at 4:02






          • 1




            Do not work with ldap group, use getent group.
            – MUY Belgium
            Apr 15 '15 at 8:50











          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',
          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%2f97657%2fhow-to-list-groups-with-gid-in-redhat%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          57
          down vote



          accepted










          The groups command lists groups that the user is currently a member of, not all the groups available on the system. You can lookup a group by name or gid using the getent command.



          getent group oinstall
          getent group 500


          To show all the groups, just leave your search query off of the command:



          getent group





          share|improve this answer



















          • 2




            @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
            – jordanm
            Oct 26 '13 at 3:02






          • 1




            @kitex I updated to wording slightly, hope that helps you understand.
            – jordanm
            Oct 26 '13 at 3:21






          • 2




            @Kitex updated the answer
            – jordanm
            Oct 26 '13 at 16:22






          • 2




            @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
            – jordanm
            Feb 1 '16 at 20:10






          • 1




            @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
            – ctrl-alt-delor
            Nov 22 at 13:35















          up vote
          57
          down vote



          accepted










          The groups command lists groups that the user is currently a member of, not all the groups available on the system. You can lookup a group by name or gid using the getent command.



          getent group oinstall
          getent group 500


          To show all the groups, just leave your search query off of the command:



          getent group





          share|improve this answer



















          • 2




            @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
            – jordanm
            Oct 26 '13 at 3:02






          • 1




            @kitex I updated to wording slightly, hope that helps you understand.
            – jordanm
            Oct 26 '13 at 3:21






          • 2




            @Kitex updated the answer
            – jordanm
            Oct 26 '13 at 16:22






          • 2




            @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
            – jordanm
            Feb 1 '16 at 20:10






          • 1




            @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
            – ctrl-alt-delor
            Nov 22 at 13:35













          up vote
          57
          down vote



          accepted







          up vote
          57
          down vote



          accepted






          The groups command lists groups that the user is currently a member of, not all the groups available on the system. You can lookup a group by name or gid using the getent command.



          getent group oinstall
          getent group 500


          To show all the groups, just leave your search query off of the command:



          getent group





          share|improve this answer














          The groups command lists groups that the user is currently a member of, not all the groups available on the system. You can lookup a group by name or gid using the getent command.



          getent group oinstall
          getent group 500


          To show all the groups, just leave your search query off of the command:



          getent group






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 26 '13 at 16:22

























          answered Oct 26 '13 at 2:55









          jordanm

          29.8k28192




          29.8k28192








          • 2




            @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
            – jordanm
            Oct 26 '13 at 3:02






          • 1




            @kitex I updated to wording slightly, hope that helps you understand.
            – jordanm
            Oct 26 '13 at 3:21






          • 2




            @Kitex updated the answer
            – jordanm
            Oct 26 '13 at 16:22






          • 2




            @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
            – jordanm
            Feb 1 '16 at 20:10






          • 1




            @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
            – ctrl-alt-delor
            Nov 22 at 13:35














          • 2




            @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
            – jordanm
            Oct 26 '13 at 3:02






          • 1




            @kitex I updated to wording slightly, hope that helps you understand.
            – jordanm
            Oct 26 '13 at 3:21






          • 2




            @Kitex updated the answer
            – jordanm
            Oct 26 '13 at 16:22






          • 2




            @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
            – jordanm
            Feb 1 '16 at 20:10






          • 1




            @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
            – ctrl-alt-delor
            Nov 22 at 13:35








          2




          2




          @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
          – jordanm
          Oct 26 '13 at 3:02




          @Kitex because you created the group but you are not a member of it. You need to add your user to the group then logout and log back in for it to show up with the groups command.
          – jordanm
          Oct 26 '13 at 3:02




          1




          1




          @kitex I updated to wording slightly, hope that helps you understand.
          – jordanm
          Oct 26 '13 at 3:21




          @kitex I updated to wording slightly, hope that helps you understand.
          – jordanm
          Oct 26 '13 at 3:21




          2




          2




          @Kitex updated the answer
          – jordanm
          Oct 26 '13 at 16:22




          @Kitex updated the answer
          – jordanm
          Oct 26 '13 at 16:22




          2




          2




          @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
          – jordanm
          Feb 1 '16 at 20:10




          @kinkajou lots of professional experience as well as a lot of time spent on sites such as this one and IRC Linux support. I have been a professional and an enthusiast for about 8 years. I think being an enthusiast is an important part because you are more likely to remember things that you care about.
          – jordanm
          Feb 1 '16 at 20:10




          1




          1




          @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
          – ctrl-alt-delor
          Nov 22 at 13:35




          @kinkajou I used Gnu/Linux for all of my computing at home. Desktops, laptops, raspberry-pi's. I have been using it since 1991 (originally Gnu on Solaris, Dec, HP). I keep adding to my knowledge; No need to through it away, and start again (as with Microsoft's Windows).
          – ctrl-alt-delor
          Nov 22 at 13:35












          up vote
          8
          down vote













          You can list groups by using getent



          When running the command, the GID is the third value in the output, e.g:



          $ getent group
          man:x:15:
          audio:x:63:
          nobody:x:99:
          users:x:100:
          <--snipped-->
          utmp:x:22:


          So to only list groupnames and their GID, use awk to print the columns you want like this:



          $ getent group | awk -F ":" '{ print $1,$3 }'
          man 15
          audio 63
          nobody 99
          users 100
          utmp 22


          See also http://man7.org/linux/man-pages/man1/getent.1.html






          share|improve this answer



















          • 6




            Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
            – jordanm
            Oct 26 '13 at 4:02






          • 1




            Do not work with ldap group, use getent group.
            – MUY Belgium
            Apr 15 '15 at 8:50















          up vote
          8
          down vote













          You can list groups by using getent



          When running the command, the GID is the third value in the output, e.g:



          $ getent group
          man:x:15:
          audio:x:63:
          nobody:x:99:
          users:x:100:
          <--snipped-->
          utmp:x:22:


          So to only list groupnames and their GID, use awk to print the columns you want like this:



          $ getent group | awk -F ":" '{ print $1,$3 }'
          man 15
          audio 63
          nobody 99
          users 100
          utmp 22


          See also http://man7.org/linux/man-pages/man1/getent.1.html






          share|improve this answer



















          • 6




            Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
            – jordanm
            Oct 26 '13 at 4:02






          • 1




            Do not work with ldap group, use getent group.
            – MUY Belgium
            Apr 15 '15 at 8:50













          up vote
          8
          down vote










          up vote
          8
          down vote









          You can list groups by using getent



          When running the command, the GID is the third value in the output, e.g:



          $ getent group
          man:x:15:
          audio:x:63:
          nobody:x:99:
          users:x:100:
          <--snipped-->
          utmp:x:22:


          So to only list groupnames and their GID, use awk to print the columns you want like this:



          $ getent group | awk -F ":" '{ print $1,$3 }'
          man 15
          audio 63
          nobody 99
          users 100
          utmp 22


          See also http://man7.org/linux/man-pages/man1/getent.1.html






          share|improve this answer














          You can list groups by using getent



          When running the command, the GID is the third value in the output, e.g:



          $ getent group
          man:x:15:
          audio:x:63:
          nobody:x:99:
          users:x:100:
          <--snipped-->
          utmp:x:22:


          So to only list groupnames and their GID, use awk to print the columns you want like this:



          $ getent group | awk -F ":" '{ print $1,$3 }'
          man 15
          audio 63
          nobody 99
          users 100
          utmp 22


          See also http://man7.org/linux/man-pages/man1/getent.1.html







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 22 at 13:00

























          answered Oct 26 '13 at 3:33









          M_dk

          1,04979




          1,04979








          • 6




            Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
            – jordanm
            Oct 26 '13 at 4:02






          • 1




            Do not work with ldap group, use getent group.
            – MUY Belgium
            Apr 15 '15 at 8:50














          • 6




            Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
            – jordanm
            Oct 26 '13 at 4:02






          • 1




            Do not work with ldap group, use getent group.
            – MUY Belgium
            Apr 15 '15 at 8:50








          6




          6




          Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
          – jordanm
          Oct 26 '13 at 4:02




          Groups are not always stored in /etc/group. They could be stored in NIS, LDAP, etc.
          – jordanm
          Oct 26 '13 at 4:02




          1




          1




          Do not work with ldap group, use getent group.
          – MUY Belgium
          Apr 15 '15 at 8:50




          Do not work with ldap group, use getent group.
          – MUY Belgium
          Apr 15 '15 at 8:50


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f97657%2fhow-to-list-groups-with-gid-in-redhat%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

          Morgemoulin

          Scott Moir

          Souastre