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?
Best Answer
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:for example
So the steps would be:
and then
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."