差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| linux:commands:manage_user_group [2024/04/19 09:27] – ↷ linux:manage_user_group から linux:commands:manage_user_group へページを移動しました。 ともやん | linux:commands:manage_user_group [2025/02/24 10:44] (現在) – [ユーザーをグループに所属させる] ともやん | ||
|---|---|---|---|
| 行 2: | 行 2: | ||
| ===== 新規ユーザーの作成 ===== | ===== 新規ユーザーの作成 ===== | ||
| - | ==== adduser / gpasswd コマンド ==== | ||
| - | ユーザーを追加する。\\ | ||
| - | < | ||
| - | $ sudo adduser hogeuser | ||
| - | </ | ||
| ==== useradd / passwd コマンド ==== | ==== useradd / passwd コマンド ==== | ||
| 行 22: | 行 17: | ||
| </ | </ | ||
| + | ==== adduser / gpasswd コマンド ==== | ||
| + | ユーザーを追加する。\\ | ||
| + | < | ||
| + | $ sudo adduser hogeuser | ||
| + | </ | ||
| ===== グループの作成 ===== | ===== グループの作成 ===== | ||
| 行 44: | 行 44: | ||
| ===== ユーザーをグループに所属させる ===== | ===== ユーザーをグループに所属させる ===== | ||
| - |   - UID、GID、グループの所属状況を確認する。< | + |   - UID、GID、グループの所属状況を確認する。< | 
| - | $ sudo id -a hogeuser | + | <WRAP color_command>< | 
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| uid=503(hogeuser) gid=503(hogeuser) 所属グループ=503(hogeuser) | uid=503(hogeuser) gid=503(hogeuser) 所属グループ=503(hogeuser) | ||
| - | </code> | + | </pre></ | 
| - | - ユーザーをグループに所属させる。<code> | + | </WRAP> | 
| - | $ sudo usermod -G wwwusers hogeuser | + | - ユーザーをグループに追加 (-a) する。<WRAP color_term> | 
| - | </code> | + | <WRAP color_command>< | 
| - | $ sudo usermod -G wwwusers, | + | <font color="# | 
| - | </code> | + | </pre></ | 
| - |   - ユーザーが指定したグループに所属していることを確認する。< | + | </WRAP> | 
| - | $ sudo id -a hogeuser | + | <WRAP color_command>< | 
| + | <font color="# | ||
| + | </pre></ | ||
| + | </WRAP> | ||
| + |   - ユーザーが指定したグループに所属していることを確認する。< | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| uid=503(hogeuser) gid=503(hogeuser) 所属グループ=503(hogeuser), | uid=503(hogeuser) gid=503(hogeuser) 所属グループ=503(hogeuser), | ||
| - | </code> | + | </pre></ | 
| + | </ | ||
| + | |||
| + | ==== 使い方 ==== | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | 使い方: usermod [オプション] LOGIN | ||
| + | |||
| + | オプション: | ||
| + |   -a, --append  | ||
| + | GROUPS に追加する。他のグループからの削除は | ||
| + | 行わない。 | ||
| + |   -b, --badname  | ||
| + |   -c, --comment COMMENT  | ||
| + |   -d, --home HOME_DIR  | ||
| + | 再設定する | ||
| + |   -e, --expiredate EXPIRE_DATE  | ||
| + |   -f, --inactive INACTIVE  | ||
| + | INACTIVEにする | ||
| + |   -g, --gid GROUP                | ||
| + |   -G, --groups GROUPS  | ||
| + |   -h, --help  | ||
| + |   -l, --login NEW_LOGIN  | ||
| + |   -L, --lock  | ||
| + |   -m, --move-home  | ||
| + | 移動する (-d が指定された場合のみ) | ||
| + |   -o, --non-unique  | ||
| + | 許可する | ||
| + |   -p, --password PASSWORD  | ||
| + |   -P, --prefix PREFIX_DIR  | ||
| + |   -r, --remove  | ||
| + | mentioned by the -G option without removing | ||
| + | the user from other groups | ||
| + |   -R, --root CHROOT_DIR  | ||
| + |   -s, --shell SHELL              | ||
| + |   -u, --uid UID                  | ||
| + |   -U, --unlock  | ||
| + |   -v, --add-subuids FIRST-LAST  | ||
| + |   -V, --del-subuids FIRST-LAST  | ||
| + |   -w, --add-subgids FIRST-LAST  | ||
| + |   -W, --del-subgids FIRST-LAST  | ||
| + |   -Z, --selinux-user  | ||
| + | ユーザマッピング | ||
| + |       --selinux-range SERANGE  | ||
| + | |||
| + | </ | ||
| + | </WRAP> | ||
| ===== ファイルやフォルダのグループを変更する ===== | ===== ファイルやフォルダのグループを変更する ===== | ||
| 行 114: | 行 174: | ||
| *4 グループのメンバーであるユーザー名のリストをカンマ区切りで設定する。\\ | *4 グループのメンバーであるユーザー名のリストをカンマ区切りで設定する。\\ | ||
| \\ | \\ | ||
| - | **参考文献**\\ | + | ===== 参考文献  | 
| [[http:// | [[http:// | ||
| [[http:// | [[http:// | ||
| + | [[https:// | ||