Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On ubuntu server, I've noticed more than once now that after adding a user to a group that user doesn't have group permissions until I reboot the system. For example:

User 'hudson' needs permission to read directory 'root:shadow /etc/shadow' So I add hudson to the shadow group. hudson still cannot read. So, I 'sudo shutdown -h -r now' and when the system comes up again user hudson can read.

Is a reboot required or is there a better way to get permissions applied after adding the user to the group?

share|improve this question
    
for future reference, I've added an actual solution below. I was amazed this was a problem. Hope that helps. –  TryTryAgain Mar 13 '12 at 3:49

3 Answers 3

When adding a user to a new group, the user must log out and log back in for it to take affect. While a reboot will accomplish that, it should not be required.

share|improve this answer
    
How do I logout a user that was created by aptitude when installing a package? –  Michael Prescott Jan 3 '10 at 1:45
    
What package creates the hudson user? –  womble Jan 3 '10 at 2:55
    
As Justin answered, try stopping and starting the service. –  Scott Pack Jan 3 '10 at 4:32
    
This is what I do. Simply log out and log back in. –  Trent Scott Sep 17 '11 at 23:10
    
You actually do not need to log out and back in, thankfully. I offered a working solution below. Tested, and HAPPY! –  TryTryAgain Mar 13 '12 at 5:12

I was looking for a solution, came across this post, and then later found one!

I'd thought I'd actually offer a solution so others can benefit. Logging in and out is so 1995.

Taken from:

https://arkaitzj.wordpress.com/2010/03/08/linux-add-user-to-a-group-without-logout/

So if you needed to get permissions for the cdrom group you just added your user to:

newgrp cdrom 

for example

So the steps would be:

#adduser my_user cdrom

and then

$newgrp cdrom

I've confirmed that it works.

A simple $groups check from the CLI shows the user is in the group. And a quick execution with needed privileges from that group works.

No need to kill your windows and login and logout! Hope that helps others!

Additional Information (based on jytou's helpful comment): "[This] solution will work only for the current opened shell. If you have another shell open, you'll need to use the same command to take the changes into account."

share|improve this answer
1  
That's great, it really works!!! :D –  dadexix86 Jul 8 '12 at 21:40
2  
Note that TryTryAgain's solution will work only for the current opened shell. If you have another shell open, you'll need to use the same command to take the changes into account. –  jytou Oct 28 '12 at 8:54
    
Very true, thanks for the addition @jytou –  TryTryAgain Oct 29 '12 at 18:09
    
Anyway to do that for the running X sesssion? –  artfulrobot Jun 27 '13 at 9:59
    
@artfulrobot sorry, I'm not exactly sure what you mean. You might want to open a new question and reference this post and solution to best be helped. –  TryTryAgain Jun 27 '13 at 19:13

Adding a user to a group does not effect currently logged in users.

In the case of a daemon, you need to restart it for new groups to be applied.

Furthermore, restarting the daemon using an option in the daemon itself will not work as that will inherit the current environment.

The easiest way to get it to work is to fully stop the daemon and start it again, as in..

/etc/init.d/foo stop ; /etc/init.d/foo start
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.