0

I added a group called developers

sudo groupadd developers

then added myself to that group

$ sudo usermod -a -G developers nick.weavers

Then I issued the command groups to check I'd been added, but got this

$ groups
nick.weavers wheel

However, if I issued the groups command with the name of the user I wanted to check like this

$ groups nick.weavers
nick.weavers : nick.weavers wheel developers

I am show to be in the developers group, but am I? Why do the two commands show different results?

2

From the groups man page (CentOS 7):

DESCRIPTION

Print  group  memberships  for each USERNAME or, if no USERNAME is specified,
for the current process (which may differ if the groups database has changed).

Adding yourself to a group does not affect the groups for processes already running, like your existing shell. This means you need to establish a new connection to see and use the permissions of the new group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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