I have a problem opening a USB port /dev/ttyUSB0.

The device node for this port is:

crw-rw---- 1 root dialout 188, 0 juil. 25 17:18 /dev/ttyUSB0

It seems that there's a problem with groups command and the group dialout as:

doom@doom-PC:~$ groups
doom adm cdrom sudo dip plugdev lpadmin sambashare
doom@doom-PC:~$ whoami
doom@doom-PC:~$ groups doom
doom : doom adm dialout cdrom sudo dip plugdev lpadmin sambashare
doom@doom-PC:~$ groups $USER
doom : doom adm dialout cdrom sudo dip plugdev lpadmin sambashare

As I am doom, why doesn't the groups command show the dialout group in its output?

And so, why I can't do this:

doom@doom-PC:~$ touch /dev/ttyUSB0 
touch: cannot touch '/dev/ttyUSB0': Permission denied

Really think that both are closely related!

This is on Ubuntu 18.04 LTS.

P.S.: If I do newgrp dialout, it works, but it is not persistent (and not user friendly).


TL;DR: It's enough to log out and back in.

This is the expected behavior. Specifically, when a user is added to a group, that user's existing sessions continue to behave as though the user is not in the group. This is almost always what's going on in a situation where a user X sees a different list of groups in groups and groups X. The groups command with no username argument shows the groups that apply to the session in which it is run.

As you observed, rebooting works, but logging off and back on is sufficient. Really, even logging off isn't necessary, in the sense that subsequent logins have the status and privileges of group membership even if previous logins are still active.

Note that the shell you have in a terminal window in Ubuntu is not a login shell (unlike in some OSes, such as macOS, where it is), so opening a new terminal window or tab has no effect.

newgrp is indeed neither persistent nor very user-friendly. But it's mostly for the situation where you want to temporarily take on a group identity. Future logins don't have to run it.

  • I have also tried to launch a new bash in the terminal with the bash command, but it doesn't work. Don't know that "terminal window in Ubuntu is not a login shell". Thanks for this explanation. Doom – doom Jul 27 '19 at 22:01
  • 1
    I have just done this a new time for another group and logout and login in Ubuntu is not enough ! I have to reboot my station to make it working. – doom Aug 11 '19 at 22:41
  • I confirm what @doom has stated, in that a log out/in was not enough, and a reboot solved this for me. – topher217 Mar 1 at 3:28

Reboot has solved the problem !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.