Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

As in the title, I wonder why there exists any difference as below:

issue "id" without username:

ygl@lyg-VirtualBox:~$ id
uid=1001(ygl) gid=1002(ygl) groups=1002(ygl),112(nopasswdlogin)

with the logged-in username:

ygl@lyg-VirtualBox:~$ id ygl
uid=1001(ygl) gid=1002(ygl) groups=1002(ygl),112(nopasswdlogin),1000(lyg),1001(vboxsf)

Are there any places other than /etc/group that store secondary groups for a user?

share|improve this question
    
Can you post /etc/passwd and /etc/group? –  Eric Carvalho Jul 30 '12 at 13:31
    
@Eric Carvalho Yes, Of course.<br/> grep ygl /etc/passwd ygl:x:1001:1002:YangLi,,,:/home/ygl:/bin/bash grep ygl /etc/group nopasswdlogin:x:112:ygl,usr2,usr1 lyg:x:1000:usr1,ygl vboxsf:x:1001:ygl,lyg,usr1,usr3 ygl:x:1002: –  LYg Jul 31 '12 at 20:52

1 Answer 1

up vote 2 down vote accepted

Are there any places other than /etc/group that store secondary groups for a user?

No, the default Ubuntu setup only relies on /etc/passwd and /etc/group for group membership.

Your first id command there, shows the groups you are in in this logged in session (i.e. what group memberships /etc/group had at the moment you logged in).

Your second id command causes it to query /etc/passwd and /etc/group, and displays information based on what those files currently contain.

Changes to group membership take effect when you log in.

share|improve this answer
    
I found what you mean in manual( type info coreutilus 'id invocation' in terminal ): Primary and supplementary groups for a process are normally inherited from its parent and are usually unchanged since login. This means that if you change the group database after logging in, 'id' will not reflect your changes within your existing login session. Running 'id' with a user argument causes the user and group database to be consulted afresh, and so will give a different result. thanks a lot! –  LYg Jul 30 '12 at 14:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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