Score:0

groups and groups are different even after restart

kp flag

Hi there I'm new to Linux and I'm very confused. I tried to add my user to docker group to run the docker without sudo as follow: https://docs.docker.com/engine/install/linux-postinstall/ and It worked (even when I closed the terminal or with my vs-code). Yesterday after I restart my computer It's looks like my user doesn't have any groups when I enter:

nitai@nitai-IdeaPad-5 ~ % id
uid=1000(nitai) gid=0(root) groups=0(root)

but when I enter my current username :

nitai@nitai-IdeaPad-5 ~ % id nitai
uid=1000(nitai) gid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),134(lxd),135(sambashare),136(docker)

It's magically finds all the groups.

I already tried to add the user again to docker group, restart the computer. I would appreciate any advice, thanks from advance.

EDIT: If I use su nitai (login from the terminal as nitai) I could see the groups in the current terminal.

Pilot6 avatar
cn flag
Are you using Ubuntu?
nitai amir avatar
kp flag
Yes , ubuntu 22.04.1
uz flag
Jos
The `groups` command gets its input from the file `/etc/group`. Are the contents of this file what you expect? There should be around 60-70 lines in it. You also may have a file `/etc/group-` or `/etc/group.org`. Perhaps these are read if `/etc/group` doesn't contain all the groups.
nitai amir avatar
kp flag
Yes ,in the /etc/group there are docker group as follow - docker:x:136:nitai,root
uz flag
Jos
I think this behaviour is expected. On my system, `sudo groups` only shows `root`, whereas `sudo groups jos` shows the whole array of groups.
Bodo avatar
pt flag
It looks like the shell is running as `root`. Please [edit] your question and show the output of `id` in the shell where `groups` displays only `root`. Copy&paste the whole command sequence with the corresponding output.
nitai amir avatar
kp flag
Thank you @Bodo I edit my question , but still I don't understand why my terminal groups and my user groups aren't the same? how do I make them the same ?
Bodo avatar
pt flag
@nitaiamir It would be better to *add* the requested information instead of replacing the other command output in your question. To me it is still not clear how you get to the shell where you are in group `0(root)`. Are you using terminal window in a graphical desktop environment? Or a (virtual) text console? How do you log in? How do you start the terminal window? Why does your user `1000(nitai)` have `gid=0(root)`? Normally you have an individual primary group, often with the same number as the `uid` or a group like `users` but not group 0. Are there any setuid or setgid programs involved?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.