0

I am trying to add one more group in already added supplementary groups for a user. rcc is the name of the supplementary group I need to add sm254040 is the user id.

when I run the command

usermod -a -G rcc sm254040

I am getting the below error:

UX: usermod: ERROR: Invalid syntax

What should I use to append a supplementary group in already added supplementary groups?

1 Answer 1

2

On Solaris 11, you use -G +groupname to add a supplementary group to a user with usermod. This is described in the manual.

usermod -G +rcc sm254040

With Solaris 10, you would have to specify all supplementary groups, including the new group, as a comma-delimited list to the -G option, as the usermod utility does not understand the + prefix syntax available in later Solaris releases, possibly through using something like:

usermod -G "$( id -Gn sm254040 | tr ' ' ',' ),rcc" sm254040

This (which is untested) would use id -Gn sm254040 to get the current groups of the user, and then tr to change the spaces into commas. This list is then appended to with the new group name and the amended list is handed to usermod -G.

4
  • can you write the command please
    – tani joshi
    Commented Jan 7, 2019 at 14:58
  • I am getting below error: UX: usermod: ERROR: group +rcc does not exist. Choose another. UX: usermod: +rcc name should be all lower case or numeric.
    – tani joshi
    Commented Jan 7, 2019 at 15:05
  • @tanijoshi See updated answer. Could you please confirm what release of Solaris you are currently running?
    – Kusalananda
    Commented Jan 7, 2019 at 20:31
  • I am currently using solaris 10. thanks for the information.
    – tani joshi
    Commented Jan 8, 2019 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .