2

I am trying to add 2 secondary groups for a user is Solaris system, but not able to do so. It only adds 1 secondary groups. I've done enough R&D, not sure what to do.

Below command I am using :

sudo usermod -g Primarygrp -G Secondarygrp1,Secondarygrp2 TJ252020

when I verify whether groups has been added or not, I use below command :-

id -Gn TJ252020

o/p I am getting- > Primarygrp Secondarygrp1

o/p I want -> Primarygrp Secondarygrp1 Secondarygrp2

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
tani joshi
  • 29
  • 1
  • 5

1 Answers1

1

According to the usermod(8) manual on Solaris, the group names should be prefixed by + to add them to the list of secondary groups.

I.e.,

usermod -g Primarygrp -G +Secondarygrp1,Secondarygrp2 TJ252020

Without the +, the secondary groups are set to the first given group. The manual hints that it's only with a + or - prefix that the -G option takes a list of groups:

When used with usermod or rolemod the –A, –G, –K, –P, and –R options may take a list of values to add or remove to the granted set using the [+|-] prefix.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936