On Mon, Apr 21, 2025 at 11:14:47PM +0200, Tomas Pospisek wrote: > On Mon, 21 Apr 2025, Marc Haber wrote: > > Well, I mean the goal of "adduser user group" is to add a user to a group... > except that - it doesn't.
I think you're confusing what you want done with what is actually done. The command "adduser foo bar" updates system records to indicate that user "foo" has membership in supplementary group "bar". The goal of this command is to update these records, and it ~does~ do this. The fact that existing shell sessions must be reinitialized is really just part of how the OS works. > 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. For example, on Debian "newgrp" creates subprocesses instead of replacing the shell. On some systems, the shell actually is replaced. Try this... $ pstree -ps $$ $ newgrp $ pstree -ps $$ It may illustrate what I'm talking about. You get a subshell, and you need to exit or logout twice to get out now. This is the case on my system, which is older… may have been updated. In light of this, I think "newgrp" is more useful for temporarily assuming a group identity to do some stuff and then backing out to your login identity. You can tell users to run "newgrp" when you add them to a group, but they'll have to do this in every open session. Also, they may be confused if they exit the new shell and they go back to their old identity. The way to avoid any confusion, I've found, is just to tell the user to "fully logout and log back in" and then go about their business. I don't think the adduser man page should make mention of newgrp. We don't own that tool (the "login" package does). Best, -- Jason Franklin