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] ユーザとグループの管理_情報管理_passwd, gpasswd, id, groups, getent

0
Last updated at Posted at 2025-06-28

passwdコマンド

$ passwd [オプション] [ユーザー名]
オプション 由来(略) 説明
default password 自分のログインパスワードを変更
- rootのみ他人のパスワードを変更可
- usermod -p と同じ
-l lock アカウントをロックする(パスワードの前に ! を付加)
-u unlock ロックされたアカウントをアンロック(! を除去)

gpasswdコマンド

$ gpasswd [オプション] [グループ名]
オプション 由来(略) 説明
default group password グループのパスワードを設定・変更する
-a ユーザー名 add member ユーザーをグループに追加
例:gpasswd -a alice developers

id コマンド

$ id [オプション] [ユーザー名]
オプション 由来 説明
default identity ユーザーの UID, GID, グループ情報を表示
-u user ID UID(ユーザーID)のみを表示
-g group ID GID(グループID)のみを表示
-G Groups すべての所属グループの GID を表示

groupsコマンド

$ groups [ユーザー名]
オプション 由来 説明
default groups - ユーザーのグループ名の一覧を表示
- 引数を省略すると、現在のユーザーのグループ情報を表示
- id コマンドは 数値(GID) を表示するが、groupsグループ名 を表示

getent コマンド

$ getent [データベース] [キー]
オプション/使い方 由来 説明
default get entries 指定したデータベース(passwd, group, hosts など)からエントリを取得
getent passwd passwd database ローカルおよび NSS 経由ですべてのユーザー情報を取得(/etc/passwd のような内容)
getent passwd ユーザー名 passwd lookup 指定ユーザーの情報のみ表示
getent group group database グループ情報一覧を表示(/etc/group 相当)
getent group グループ名 group lookup 指定グループの情報のみ表示
getent hosts group database ホスト情報一覧を表示(/etc/hosts 相当)
getent hosts ホスト名 group lookup 指定ホストの情報のみ表示

Ping-t

全般

gpasswd

id

groups

getent

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?