As I know the groups command and the id command should both in their output display the secondary groups of a user. But in my case the output differ from each other:

$ id <username>
uid=1000(username) gid=1000(username) groups=1000(username)

$ groups
username adm cdrom sudo dip plugdev lpadmin sambashare libvirt

Im am using Ubuntu version 18.04.1.

I also check the /etc/group file and I don't see any entry for the groups that the groups command shows related to the specified username. Should it not actually be the secondary group information to username mapping in this file? I was expecting that next to the name of the group, lets say cdrom, to see the username I used for the groups command!

If it helps, the output of the ps -o egid,rgid,pid,ppid,cmd | grep bash command is:

1000   1000   30061   29959   /bin/bash
1000   1000   31747   30061   grep --color=auto bash

Update: I checked that the output of the id command without specifying a username displays all the groups like the groups command but executing the same command specifying the username id username does not shows the other groups. In the man page of the id command it says.

id [OPTION]...[USER] Print user and group information for the specified USER, or (when USER omitted) for the current user.

In this case it should be the same output because it is about the same user.

  • what is the output for ps -o egid,rgid,pid,ppid,cmd | grep bash. put your shell if you are not using bash. (zsh, csh,...)
    – binarysta
    Commented Jun 22, 2020 at 10:49
  • @binarysta I added the output of that command to my question. Please see it there. Thnx.
    – Elio
    Commented Jun 22, 2020 at 11:00
  • so what if you start a new shell and check again the id and groups? the result is same?
    – binarysta
    Commented Jun 22, 2020 at 11:18
  • @binarysta yes it is the same. Please check also my last update. id and groups displays the same output but the id <username> does not display the other groups.
    – Elio
    Commented Jun 22, 2020 at 11:21
  • ok is there any other user with 1000 uid? grep 1000 /etc/passwd ?
    – binarysta
    Commented Jun 22, 2020 at 11:26


You must log in to answer this question.

Browse other questions tagged .