On Tue, 22 Apr 2025, Jason Franklin wrote:
On Tue, Apr 22, 2025 at 09:54:54AM -0400, Jason Franklin wrote:
At some point I have somehow found out that using some other magic in
addition is necessary. Other users of adduser might not know and just think
that `adduser user group` doesn't work or is broken or ...
I actually wouldn't rely on "newgrp" too much for this purpose. It may
not work the way you think.
To follow up on what I said here, I also want to address the patch you
provided as this may be different than what you think as well.
If you do…
# adduser foo bar
… you have added user "foo" to group "bar" where the latter is now
a supplementary group for the former (i.e., you've updated system
records).
If the user now runs "newgrp bar", the user will assume "bar" as their
primary group. This is ~not~ the same as having the group appended to
their supplementary groups in their current shell session.
There are other differences, but "log out & log in" remains the best and
most complete and correct advice for this situation. It provides the
most predictable result for the user.
I agree with that