I did a usermod to add the current user user in a group, but when I run id -Gn it only shows the main user's group:
[user@computer ~]$ id -Gn
user
But when I specify the user, it works normally:
[user@computer ~]$ id -Gn user
user newgroup
Do you have an idea why it works like it? Am I missing something concerning the groups management in UNIX?
id -Gn user,idwill perform a group lookup based on/etc/group. When callingid -Gn,idwill only lookup groups registered in the current session (that is, for the current user). – John WH Smith Aug 10 '14 at 15:22strace id, you can see it read information from/etc/group. – cuonglm Aug 10 '14 at 15:25/etc/groupfile is the default way group information is stored. Systems can supplement it with other sources such as YP/NIS and LDAP. Theidandgetentcommands will query whatever source(s) the system uses. (Likewise for/etc/passwdand several other databases). – Keith Thompson Aug 10 '14 at 19:15idreads/etc/groupin either case is not relevant.idwill callgetgroups(3), which returns an array ofgid_ttypes (integers) for the current session.idneeds to scan the/etc/groupfile to retrieve the names for the groups (e.g.100(users),10(wheel)...). When you give a username toid, it has to open the/etc/passwdfile to get the user ID, then it finds groups that this user belongs to in the/etc/groupfile. – sleblanc Aug 10 '14 at 19:21newgrp -might also be useful. – bishop Aug 10 '14 at 19:54/etc/group. – JdeBP Jun 22 '20 at 17:48