How to become a member of a group without relogin (Linux)

George Shuklin
OpsOps
Published in
1 min readApr 28, 2019

Today I found two things: one useful, an another from a realm of ‘too much’.

Useful part: how to become a member of a newly created group on your workstation without relogin/reboot? Let’s say you’ve install libvirt (and qemu) and wants to have an access to virt-manager right away.

The answer: newgrp command allows you to do this. It changes your primary group to a given group. To avoid miss-attribution of created files, another call to newgrp (with no arguments) restore the original primary group, but keeps membership in other groups (including freshly added).

sudo apt install virt-manager
sudo adduser `whoami` libvirt
newgrp libvirt
newgrp

So far so good. The ‘too much’ part comes from newgrp manpage.

There are group passwords in Unix. And in Linux. man gpasswd.There is /etc/gshadow file, and sad notice on older security practices in the manpage:

Notes about group passwords
Group passwords are an inherent security problem since more than one person is permitted to know the password. However, groups are a useful tool for permitting co-operation between different users.

Sad, sad piece of legacy we all bear in our systems.

--

--

George Shuklin
OpsOps

I work at Servers.com, most of my stories are about Ansible, Ceph, Python, Openstack and Linux. My hobby is Rust.