The /etc/sudoers.d/user1
file contains:
%user1 ALL=(user1) NOPASSWD:ALL
Which using the sudo
command grants all users of the user1
group (%user1
) to login to the user1
user (ALL=(user1)
) without the need for a password.
If after adding the user1
group to the current user myuser
, a reboot is not performed, then using the sudo command it keeps asking me for a password to login to the user1
user until the next reboot because the user groups are not reloaded.
In fact, if I run the groups myuser
command, I get:
myuser : myuser adm cdrom sudo dip plugdev lpadmin lxd sambashare user1
If instead I run the groups
command, I get:
myuser adm cdrom sudo dip plugdev lpadmin lxd sambashare
without the group user1
.
How do I reload user groups without reboot and without ugly hacks for use in a bash script?
I've already read the solutions proposed by the various StackExchange links ad nauseam, they don't satisfy me, as I want to remain in the same shell session during the reload or temporarily open a new one and close it again at the end of the command useful for reloading user groups, because everything is contained within a giant script.
I use Ubuntu 22.04 LTS Desktop 64-bit
.
user1
group exist already or did you just create it? If it was a pre-existing group, did you add the user with which you are testing the sudo command to it in the same session as that in which you updated the sudoers file?user1
(therefore also the group of the same name), associates the current user to that group and then creates the file/etc/sudoers.d/user1
in the same session.user1
group, restart the computer and put me back in theuser1
group, then it asked me again for the password to login to theuser1
user. In fact, the specific problem is that thegroups myuser
command returns:myuser : myuser adm cdrom sudo dip plugdev lpadmin lxd sambashare user1
. With thegroups
command it returns:myuser adm cdrom sudo dip plugdev lpadmin lxd sambashare
without the groupuser1
. How do I update groups?su - user1