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?

More than 5 years have passed since last update.

RHEL ユーザ設定方法

Last updated at Posted at 2019-11-20

ユーザの確認方法とは?

catコマンドの利用

# cat /etc/passwd 
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
:
:
test:x:1001:1001::/home/test:/bin/bash

上記のようにただcatでファイルの中身を見ると無数のユーザーが表示されてしまうので、表示したいユーザーのみ表示して確認します。
ピンポイントで確認するときは、パイプ「 | 」でつなぎ、grepコマンドを利用します。
※/etc/passwdファイルは参照するのみで書き込みはしません。

# cat /etc/passwd | grep test
test:x:1001:1001::/home/test:/bin/bash

以上が確認コマンドです

ユーザーの追加方法

useraddコマンドを利用し、catコマンドで追加されたことを確認します。

[定型文]
# useradd 追加するユーザー名

[使用例]
# useradd test

# cat /etc/passwd | grep 追加したユーザー名

ユーザーの削除方法

-rオプションによりhomeディレクトリごとまとめて削除できます。
削除した後、catコマンドにて削除されたことを確認してください。

# userdel -r ユーザー名
# cat /etc/passwd | grep 削除したユーザー名

パスワードの設定をしたい場合

[定型文]
# passwd 設定したいユーザー名

[使用例]
# passwd test
ユーザー testのパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: すべての認証トークンが正しく更新できました。

ユーザーの設定変更をしたい場合

[定型文]
# usermod オプション ユーザー名

[使用例]
# usermod -L test

オプションの例は下記の通りです。

オプション 説明    
-a 副グループを変更する 
-c コメントを変更する
-g 主グループまたはグループ番号(GID)を変更する
-G 副グループを変更する
-u ユーザー IDを変更する
-o 既存のユーザー番号(UID)と同じ番号にユーザーを変更する
-d ユーザーの作業用ディレクトリを変更する   
-m ホームディレクトリの内容を移動する   
-e ユーザーの有効期限を変更する   
-f パスワードの有効期限が切れた後のユーザーのアカウントの有効期限を変更する   
-L ユーザーをロックする   
-U ユーザーのロックを解除する   

引用

Linuxユーザー一覧の確認と、/etc/passwdファイル項目

https://kazmax.zpp.jp/linux_beginner/etc_passwd.html

usermodコマンド

https://eng-entrance.com/linux-command-usermod

以上がユーザ設定方法です。
最後までお読みいただきありがとうございました!

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?