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.