自宅サーバー ≫ Linux Server ≫ CentOS 7 ≫ ユーザーの登録

 
ユーザーの登録
何でも出来る root でログインするのはセキュリティー上問題があるので新しくユーザーを登録して通常はそのユーザーでログインし、必要に応じて root になるようにする
 
 
[root@centos]# useradd xxxx   (xxxx と言うユーザーを追加)
 [root@
centos]# passwd xxxx    (xxxx のパスワード設定)
 New UNIX password:
******
     <--- パスワード入力(* は実際には表示されません)
 Retype new password: ******
   <--- 再度  パスワード入力(* は実際には表示されません)
 
また、誰でも root になれるのは問題がありますので今回登録したユーザー xxxx だけが root になれるように設定

ここからの設定は root でログインしていないと出来ないので root でログイン

 
 
[root@centos]# usermod -G wheel xxxx   (ユーザxxxxをwheelグループに追加 )
 
su設定ファイルの編集
 
 
[root@centos]# 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     required      pam_wheel.so use_uid

 
 
以下略
 
PC起動時の自動起動設定
 
 
[root@centos]# vi /etc/login.defs
 SU_WHEEL_ONLY yes
   <--- 最終行に追記
 
なお、ユーザーを削除する場合
 
 
[root@centos]# userdel xxxx   (xxxx と言うユーザーを削除)
 
また、ユーザーをディレクトリごと削除する場合
 
 
[root@centos]# userdel -r xxxx   (xxxx と言うユーザーをディレクトリごと削除)
 

戻る