Difference between id and groups


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Difference between id and groups
# 1  
Old 10-29-2010
Difference between id and groups

What's the difference between groups and id-a.

We're using LDAP, rather than NIS+, and a user has been added to an extra Unix group. The groups command shows the new group but id -a doesn't!

Why would this be?
# 2  
Old 10-29-2010
the session of the user is attached to a primary group id
this primary group id is diplayed with the id command.

If the user want his session be active with another group id (for example, one of the possible secondary group id) he can switch of activ group id using the newgrp command

Note that this will not change his default group id (if he disconnect / reconnect, he will be back in is primary group id).
Code:
see -g and -G option of useradd/usermod

you can try to newgrp you user to a <secondary_group_id> and do id again

by the way, the output of your id command may depends on your OS
Code:
# id
uid=0(root) gid=0(root) 
# newgrp sys
# id
uid=0(root) gid=3(sys) 
#

# 3  
Old 10-29-2010
Thanks, but I don't want to change groups. I simply want to understand why the groups and id outputs differ.
# 4  
Old 10-29-2010
then you have to go through the RTFM part ...
Code:
man id 
man groups

...
maybe historical reasons ...
Code:
# id -a
uid=0(root) gid=0(root) groups=0(root),1(other),2(bin),3(sys),4(adm),5(uucp),6(mail),7(tty),8(lp),9(nuucp),12(daemon)
# groups
root other bin sys adm uucp mail tty lp nuucp daemon
#

Maybe it depends some OS but as you see for example on a Sun Sparc system :
id -a show not only the groupname but also the corresponding groups id whereas the output of groups only show the name of the group the user belong to, by the way this output may require less parsing if you use it in a script
# 5  
Old 11-03-2010
...but in your example it's the same set of groups for either command.

I'm seeing an extra group running groups than I see with id -a.
# 6  
Old 11-03-2010
how did you add the user to a second group? POSIX allows up to 16 groups for a user.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Solaris

Solaris 10 groups

I have a Solaris 10 system inherited from several previous admins. While trying to decipher a permissions issue, I ran "grpck" and it reported a ton of errors. Among them were these: 1. group name too long 2. group name contains illegal characters (special chars or caps) 3. group membership... (2 Replies)
Discussion started by: cjhilinski
2 Replies

3. Solaris

Groups is not visible

OS : SunOS 5.8 I am trying to add a user ad3059 to the following groups, A B C D ( four groups A,B,C,D) When i use usermod command and add the user to the above groups, and go to > groups ad3059 other C D It doesnt show A and B groups and shows it as other.Please advice on how... (13 Replies)
Discussion started by: Revathi2089
13 Replies

4. Programming

what is the main difference between difference between using nonatomic lseek and O_APPEND

I think both write at the end of the file ...... but is there a sharp difference between those 2 instruction ..... thank you this is my 3rd question today forgive me :D (1 Reply)
Discussion started by: fwrlfo
1 Replies

5. UNIX for Dummies Questions & Answers

Groups

Must I be in a group? I am using Ubuntu and am the only user on my PC. I know how to change groups but do not see a way to not be in a group. Any help would be appreciated. (2 Replies)
Discussion started by: nthepines
2 Replies

6. UNIX for Dummies Questions & Answers

Understanding Groups

Hi cat /etc/group : .... oinstall:x:401: dba:x:400:oracle ... cat /etc/passwd|grep oracle oracle:x:130:401::/home/oracle:/bin/ksh 1. Is that mean that : ORACLE user has OINSTALL as it Primary group and DBA as secondary group ? 2. What is the linux comman to set ORACLE user with... (2 Replies)
Discussion started by: yoavbe
2 Replies

7. Solaris

groups

1 user in member of 4 groups find file permissions and default group (1 Reply)
Discussion started by: tirupathi
1 Replies

8. Solaris

groups

how to create 1000 users in 1 group (0 Replies)
Discussion started by: tirupathi
0 Replies

9. Windows & DOS: Issues & Discussions

putty groups

Hi all, need info on using putty as group. I am having huge numbers of servers. (say 100) I am using putty to login remotely. i want to group each 25 hostnames or a set of servers into one putty instance. (see image attached.) Currently i have to scroll down to see all the 100 servers. ... (2 Replies)
Discussion started by: karthikn7974
2 Replies

10. AIX

Where are my groups

Hello A couple of weeks ago, I added a user to an AIX 5.3 system. I go to add one today, and it appears that when creating a user in smit, I cannot see any groups. No primary groups No Group set No Admin Groups The /etc/group and etc/secuity/group files seem to be intact. I did... (4 Replies)
Discussion started by: mhenryj
4 Replies
Login or Register to Ask a Question