How to list groups with gid in redhat?
up vote
33
down vote
favorite
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
add a comment |
up vote
33
down vote
favorite
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
add a comment |
up vote
33
down vote
favorite
up vote
33
down vote
favorite
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
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
rhel command
asked Oct 26 '13 at 2:51
kinkajou
2851411
2851411
add a comment |
add a comment |
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
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 thegroups
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
|
show 9 more comments
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
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, usegetent group
.
– MUY Belgium
Apr 15 '15 at 8:50
add a comment |
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
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 thegroups
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
|
show 9 more comments
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
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 thegroups
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
|
show 9 more comments
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
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
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 thegroups
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
|
show 9 more comments
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 thegroups
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
|
show 9 more comments
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
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, usegetent group
.
– MUY Belgium
Apr 15 '15 at 8:50
add a comment |
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
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, usegetent group
.
– MUY Belgium
Apr 15 '15 at 8:50
add a comment |
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
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
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, usegetent group
.
– MUY Belgium
Apr 15 '15 at 8:50
add a comment |
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, usegetent 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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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