Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After I edit /etc/group and I add a user to groups it didn't belong to, the user will not be able to use it's newly acquired privileges unless it starts a new session.

Is there a command to refresh user/group properties in an ongoing session?

share|improve this question

migrated from Mar 22 '10 at 14:32

This question came from our site for professional and enthusiast programmers.

Is there a reason you're editing the file by hand instead of using useradd -G groupname username? – Bobby Jun 15 '10 at 8:28
@Bobby: this would make no difference. – niXar Jun 15 '10 at 10:09

At the kernel level, group membership is a property of each process. Unless it has the appropriate capability (CAP_SETGID if I'm not mistaken), i.e. root privileges for all intents and purposes, a process cannot belong to a new group.

A user does not exist as an object at the kernel level; only processes (and files) do. A process has a uid (effective and whatnot) and a list of group ids.

When you are adding a user to a group, the kernel has no idea what it means. It only knows, indirectly, that the next time /bin/login or /usr/bin/newgrp is run a process with that user id will have a new group id in its list.

So, to answer your question, if you're speaking of a Gnome or KDE session, you have to restart it indeed. Or if you only care about the result of one command as far as that new group is concerned, you can use newgrp I just mentioned. It will start a new shell with the newly added group.

share|improve this answer

I've read before that the newgrp command does this, but only for the current shell. There doesn't seem to be a better alternative than to log out and back in again.

share|improve this answer
What newgrp does is actually start a new shell. So if you ^D from it you're back to your old shell. I usually simply do 'exec newgrp' – niXar Jun 15 '10 at 10:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.