Answers for "add group without logout"

0

add group without logout

# Horribly hacky, but you could use two layers of newgrp to achieve this for a particular group:

id -g

# ...will give you the current primary group ID. We'll call this orig_group for the purposes of this example. Then:

newgrp <new group name>

# ...will switch you to that group as the primary and add it to the list of groups returned by groups or id -G. Now, a further:

newgrp <orig_group>

# ...will get you a shell in which you can see the new group and the primary is the original one.
# This is horrible and will only get you one group added at a time, but it has helped me out a couple of times to get groups added without logging out/in my whole X session (e.g. to get fuse added as a group to a user so that sshfs will work).
# Edit : This doesn't require you to type your password either, which su will.
Posted by: Guest on June-14-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language