linux - Where & How is user group information stored in Ubuntu? -


mirror question: https://unix.stackexchange.com/questions/217300/where-how-is-user-group-information-stored-in-ubuntu. (i'll remove 1 of them after got answer)


two places possible: /etc/group , /etc/passwd.

if use command: adduser [username] [groupname], user added group, , file /etc/group updated.

however, file /etc/passwd not updated. if check group belongs to, via groups command, can see groups stated in passwd file.. therefore, user not added group base on result.


i'm confused.

  1. what's meaning of storying group info /etc/passwd, , /etc/group respectively?
  2. why adduser update group file?
  3. how add group passwd file via command?
  4. why groups return group info passwd file, not group file?

thanks.

  1. in these traditional text files (there other ways, e.g. ldap), primary group goes /etc/passwd (it's e.g. used permissions of files create), additional groups go /etc/group.
  2. see 1.
  3. that's impossible, can change primary group usermod -g
  4. that's misinterpretation, groups shows all groups. new group picked when start new session (new login). can use newgrp command, starts session given group name primary group (you must member of group) -- side effect, consult user database , update groups list.

Comments