Linux-usermod:增加已建立用户的用户组

usermod --help

-g, --gid GROUP               force use GROUP as new primary group
-G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing

说明:再已有用户想要增加用户组时,root用户给risk用户增加oinstall组,risk和oinstall组均已存在的情况

参数:-g

usermod -g oinstall risk
这种情况下会直接修改risk的用户组,覆盖原来的组

参数: -a -G

usermod -a -G oinstall risk
这种情况下会追加修改risk的用户组,新增oinstall用为risk的从属用户组,不覆盖原有的risk的用户组。
原文地址:https://www.cnblogs.com/moox/p/11381869.html