プログラミング学習サイト

プログラミングの学習を開始される方を対象としたプログラミング入門サイトです。

groupaddコマンドとは何か

参考 : https://ss64.com/bash/groupadd.html

groupaddコマンドとは

新しいグループを作成します。

groupadd [options] *group* 

コマンドラインで指定された値とシステムのデフォルト値を使用して、新しいグループアカウントを作成します。 新しいグループは、必要に応じて各種システムファイルに入力されます。

オプション一覧

  • -f, --force

    • 使用ケース: グループが既に存在している場合でもエラーを返さず、新たに作成しない。グループが存在せず、指定されたGIDが既に使用されている場合は、次の利用可能なGIDを選択します。
    • コマンドの例: sudo groupadd -f group_name
  • -g, --gid GID

    • 使用ケース: 指定されたGID(グループID)を持つ新しいグループを作成します。
    • コマンドの例: sudo groupadd -g 1001 group_name
  • -K, --key KEY=VALUE

    • 使用ケース: 設定ファイル /etc/login.defs で指定されたデフォルト値をオーバーライドします。
    • コマンドの例: sudo groupadd -K GID_MIN=1000 group_name
  • -o, --non-unique

    • 使用ケース: 重複するGIDの使用を許可します。このオプションは -g オプションと一緒に使用されます。
    • コマンドの例: sudo groupadd -o -g 1000 group_name
  • -p, --password PASSWORD

    • 使用ケース: 新しいグループに設定するパスワードを指定します。パスワードは暗号化された形式で指定する必要があります。
    • コマンドの例: sudo groupadd -p $(openssl passwd -1 password) group_name
  • -r, --system

    • 使用ケース: システムグループを作成します。通常のユーザーグループとは異なり、システムグループは特定のシステムタスクやデーモンのために使用されます。
    • コマンドの例: sudo groupadd -r system_group_name

groupaddでの設定

/etc/login.defの次の構成変数は、このツールの動作を変更します。

gid_max(number)、gid_min(number) UserAdd、GroupAdd、またはNewusersによる通常のグループの作成に使用されるグループIDの範囲。

MAX_MEMBERS_PER_GROUP (number) Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group. This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters. If you need to enforce such limit, you can use 25. Split groups might not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it.[error]

sys_gid_max(number)、sys_gid_min(number) userAdd、GroupAdd、または新入生によるシステムグループの作成に使用されるグループIDの範囲。

関連ファイル

   /etc/group       Group account information. 
   /etc/gshadow     Secure group account information. 
   /etc/login.defs  Shadow password suite configuration.

Caveats[error]

GroupNamesの長さは最大32文字しかありません。 NISまたはLDAPグループを追加することはできません。これは、対応するサーバーで実行する必要があります。 GroupNameがNISLDAPなどの外部グループデータベースに既に存在する場合、GroupAddはグループ作成要求を拒否します。

Exit Values[error]

The groupadd command exits with the following values:[error]


   0     success 
   2    invalid command syntax 
   3    invalid argument to option 
   4    GID not unique (when -o not used) 
   9    group name not unique 
  10    can’t update group file

groupdel - Delete a group. groupmod - Modify a group. useradd - Create new user account. Equivalent Windows command: dsadd - Add active directory object.[error]


  Copyright © 1999-2024 SS64.com[error]

Some rights reserved https://ss64.com/bash/groupadd.html