Fedora 31
Sponsored Link

初期設定 : 一般ユーザーを新規追加する2019/11/04

[1] 一般ユーザーを追加する場合は以下のように設定します。
[root@localhost ~]#
useradd fedora

[root@localhost ~]#
passwd fedora

Changing password for user fedora.
New UNIX password:              # 設定したいパスワードを入力
Retype new UNIX password:       # パスワード再入力
passwd: all authentication tokens updated successfully.
[2] root ユーザーアカウント (管理者ユーザー) にスイッチする場合は以下のように実行します。
誤操作を避けるため、必要がある時のみ root ユーザーにスイッチして作業した方がよいでしょう。
localhost login: fedora         # ログインユーザー名を入力
password:                       # パスワード入力
[fedora@localhost ~]$
su -
    
# rootユーザーに遷移

Password:                       # rootパスワード入力
[root@localhost ~]#             # rootユーザーに遷移完了
[3] root ユーザーアカウントにスイッチ可能なユーザーを限定したい場合は以下のように設定します。
例として [1] で追加した fedora のみに限定するよう設定します。
[root@localhost ~]#
usermod -aG wheel fedora

[root@localhost ~]#
vi /etc/pam.d/su
#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth           sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
# 以下の行頭の # を削除してコメント解除
auth            required        pam_wheel.so use_uid
auth            substack        system-auth
auth            include         postlogin
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         include         postlogin
session         optional        pam_xauth.so

# 許可したユーザー以外でログインして確認

[redhat@localhost ~]$
su -

Password:
su: Permission denied     # 設定通り拒否された
[4] システムからユーザーを削除する場合は以下のように設定します。
# [fedora] ユーザー削除 (ユーザーの削除のみ)

[root@localhost ~]#
userdel fedora
# [fedora] ユーザー削除 (ホームディレクトリも削除)

[root@localhost ~]#
userdel -r fedora
関連コンテンツ