usermodまたはgroupmodを使用して他の既存のグループにユーザーを追加することに違いがあるかどうか疑問に思います。例: Artists という補助グループがあり、このグループに Romeo を追加しようとしています。
usermod -G artists romeo
groupmod -U romeo artists
私はRed Hat 9を使用しています。
ベストアンサー1
man
ページからgroupmod
:
The groupmod command modifies the definition of the specified GROUP
by modifying the appropriate entry in the group database.
オプションはありません-U
(2022年4月18日付Shadow-utils 4.6)。目的は、groupmod
メンバーの属性ではなくグループの属性を変更することです。
man
ページからusermod
:
-G, --groups GROUP1[,GROUP2,...[,GROUPN]]]
A list of supplementary groups which the user is also a member of ...
If the user is currently a member of a group which is not listed, the user
will be removed from the group. This behaviour can be changed via the -a
option, which appends the user to the current supplementary group list.
たとえば、ユーザーがromeo
すでにグループのメンバーである場合は、paintworkers
次のようにします。
usermod -G artists romeo
artists
彼はそのメンバーではなくサプリメントグループのメンバーですpaintworkers
。ただし、以下を使用する場合:
usermod -aG artists romeo
彼は2つのグループのメンバーになります。
修正する:
上記のように、これはshadow-utils
2022年4月18日4.6にも当てはまります。ただし、OPはshadow-utils
2021年2月12日4.9が現在以下を記録していると指摘しています-U
。
-U, --users
A list of usernames to add as members of the group.
したがって、おおよそのusermod -aG
またはgroupmod -U
フォーマットは将来のバージョンにも同じように適用する必要がありますshadow-utils
。