10

I have a weird problem in that my user (on Linux Mint 18.3 Sylvia) is part of group docker, which I verify by starting a terminal:

$ groups
me adm cdrom sudo dip plugdev lpadmin sambashare docker

Now, when I fire up tmux, and run the same command, suddenly my docker membership disappears:

$ tmux
$ groups
me adm cdrom sudo dip plugdev lpadmin sambashare

The weird thing is, when I attempt to forcibly add my user to the group docker when in tmux, it says I'm already in it!

$ sudo adduser me docker
The user `me' is already a member of `docker'.

I'm stumped -- why would being in tmux make a difference? For reference, I use fish shell and this is my .tmux.conf:

$ cat ~/config/.tmux.conf 
new-session
set -g default-terminal "screen-256color"
set -g history-limit 10000
setw -g mode-keys vi
set-option -g default-shell /usr/bin/fish
set-option -g default-command /usr/bin/fish

EDIT

When I restarted my computer, everything worked again (both tmux and "normal" shells showed my docker membership). I'm still curious -- why did this happen?

ilkkachu
  • 133,243
  • 15
  • 236
  • 397
ash
  • 209
  • 1
  • 6
  • Are you using the same version of `groups` in both shell environments? Have you tried using other commands to show group membership, such as the `getent` or `id` commands? – igal Mar 15 '18 at 12:34
  • 2
    Your example shows you creating a new tmux session. Are you sure you didn't do `tmux attach` instead? – Andy Dalton Mar 15 '18 at 14:12
  • @AndyDalton I don't think I did `tmux attach`, I just ran `tmux` and it's not aliased to anything as far as I can tell. – ash Mar 15 '18 at 15:11
  • 1
    It seems to be duplicate of https://stackoverflow.com/questions/18673016/in-tmux-i-only-have-2-groups. – Kuldip Nanda Aug 27 '19 at 11:51
  • Does this answer your question? [I added a user to a group, but group permissions on files still have no effect](https://unix.stackexchange.com/questions/6387/i-added-a-user-to-a-group-but-group-permissions-on-files-still-have-no-effect) – ilkkachu Aug 18 '21 at 07:18
  • `adduser` just edits a file (the `/etc/groups` file. It does not add a process to a group. – ctrl-alt-delor Nov 29 '21 at 17:30

3 Answers3

2

The most likely explanation for this is that the tmux session was started before you added your user to the docker group. Note that you can log out without terminating an active tmux session, but that this session would not be affected by changes in group memberships when you re-attach to it after logging in again later.

In your edit to the question you say that when you started a new tmux session (after a reboot), the user shows up as member of the docker group. This is expected as you now have a tmux session started from an environment where the group memberships had been altered.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
2

I just had the same issue. I had to close all existing tmux sessions. After that, all new tmux sessions inherited the correct groups.

schreon
  • 121
  • 2
0

You can delete your tmux session file:

rm /tmp/tmux-1000 # example for uid 1000

Then start a new session and see that you are a member of the group.