Jobs Fast Jobs Fast

Linux: Refresh group membership without logging out

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)

Posted Thursday, October 21st, 2010 under linux, tips and tricks.

Tags: , ,

4 comments

  1. 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.

  2. Great, thank you noting this little trick.

  3. Also, newgrp works too!

    useradd -G -a myGroup myUser
    newgrp myGroup

    Tada! :)

  4. @Chad, thanks for the tip. Unfortunately, this doesn’t work for me, neither did “newgrp -” which I had some hope in.

Leave a Reply