6

I'm preparing for the LPIC-1, exam 102, and was wondering what is the difference between these two commands with respect to options -G and -aG:

  1. usermod -G projectA, projectB jsmith
  2. usermod -aG projectA, projectB jsmith

The user jsmith has its own default group, which is not listed above among the groups/projects.

As I understand from the man pages of usermod, in (1) jsmith is taken off the listed groups/projects. In (2), the user is appended to those groups listed after -G and this does not affect its belonging to its default group.

Do I correctly interpret the usage of these two options?

AdminBee
  • 21,637
  • 21
  • 47
  • 71
WobblyWindows
  • 727
  • 1
  • 9
  • 24

1 Answers1

10

usermod -G sets the user’s supplementary groups to only the groups specified; so after running

usermod -G projectA,projectB jsmith

the jsmith user will belong to projectA, projectB, and its “primary” group.

usermod -aG adds the specified groups to the user’s supplementary groups; so after running

usermod -aG projectA,projectB jsmith

the jsmith user will belong to projectA and projectB in addition to any groups it already belonged to (including its primary group).

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164