0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Linux] ユーザとグループの管理_ユーザー管理_useradd, usermod, userdel

Last updated at Posted at 2025-06-11

useraddコマンド

# useradd [オプション] ユーザー名
オプション 由来 説明
default user add 新しいユーザーアカウントを作成するためのコマンド
-d directory ユーザーのホームディレクトリを指定
例:/home/username
-m make home ホームディレクトリを自動作成
-s shell ログインシェルを指定
例:/bin/bash
-g group プライマリグループ(GID または グループ名)を指定
-G Groups セカンダリグループをカンマ区切りで複数指定
例:wheel,users
-u UID ユーザーID(UID)を指定
-c comment コメント(通常はユーザーのフルネーム)を指定
-p password 暗号化されたパスワードを指定
-D default デフォルト設定の表示・変更を行う
例:useradd -D で確認
例:useradd -D -s /bin/zsh で変更

usermodコマンド

# usermod [オプション] ユーザー名
オプション 由来 説明
default user modify 既存のユーザーアカウントを変更するためのコマンド
-d directory ユーザーのホームディレクトリの新しいパスを指定
-s shell ログインシェル(例:/bin/bash)を変更する

シェルを無効化する:
- /bin/false:即時終了しログイン不可
- /sbin/nologin:ログイン拒否メッセージを表示して終了(より適切・推奨)
-g group プライマリグループ(GID)を変更
-G Groups セカンダリグループをカンマ区切りで指定し追加
-L lock ユーザーアカウントをロック(パスワードの先頭に ! を付けてログイン不能に)
-U unlock -L でロックしたアカウントをアンロック(! を除去)

userdelコマンド

# userdel [オプション] ユーザー名
オプション 由来 説明
default user delete 指定したユーザーを削除
ホームディレクトリは削除しない
-r remove home directory 指定したユーザーを削除
ホームディレクトリを削除
-f force 強制削除
- ログイン中のユーザーでも削除可能

Ping-t

全般

useradd

usermod

userdel

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?