Have you ever added yourself to a group by editing /etc/group then realized the change doesn’t take effect until next time you log in (or spawn a new shell)?
Found this nice trick out today:
exec su -l $USER
(Note: it makes you re-enter your password, but you don’t have to restart sessions)
RSS Feed
Dude! Neat trick. I knew you could do the “su – username”
But the exec part replaces the existing shell, this way Ctrl-D and exit still work the way they are supposed to. Nice!
I am not sure you need the -l though.
Great, thank you noting this little trick.
Also, newgrp works too!
useradd -G -a myGroup myUser
newgrp myGroup
Tada!
@Chad, thanks for the tip. Unfortunately, this doesn’t work for me, neither did “newgrp -” which I had some hope in.