Centos 7新規ユーザーの追加と承認


新規ユーザーの作成


ユーザー名:linuxidc
[root@localhost ~]# adduser linuxidc

このユーザーのパスワードを初期化すると、linuxはパスワードの複雑さを判断しますが、無視することができます.
[root@localhost ~]# passwd linuxidc
  linuxidc   。
   :
 :   -  / 
   :
passwd: 。

権限


個人ユーザーの権限は本homeの下でのみ完全な権限を持つことができ、他のディレクトリは他の人の権限に依存します.rootユーザーの権限が必要になることが多く、sudoはrootに変身して操作することができます.私はsudoがファイルを作成したことを覚えています.そして、表示権限がrootによって作成されたため、自分が読み書き権限を持っていないことに気づきました.
新しく作成されたユーザーはsudoコマンドを使用することはできません.彼に権限を追加する必要があります.
sudoコマンドのライセンス管理はsudoersファイルにあります.sudoersを見てみましょう.
[root@localhost ~]# sudoers
bash: sudoers:  ...
[root@localhost ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz

このファイルの場所を見つけてから、アクセス権を表示します.
[root@localhost ~]# ls -l /etc/sudoers
-r--r----- 1 root root 4251 9   25 15:08 /etc/sudoers

はい、読み取り専用の権限しかありません.変更するには、w権限を追加する必要があります.
[root@localhost ~]# chmod -v u+w /etc/sudoers
mode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----)

その後、コンテンツを追加できます.次の行に新しいユーザーを追加します.
[root@localhost ~]# vim /etc/sudoers


## Allow root to run any commands anywher  
root    ALL=(ALL)       ALL  
linuxidc  ALL=(ALL)       ALL  # 

wq保存が終了したら、書き込み権限を回収することを忘れないでください.
[root@localhost ~]# chmod -v u-w /etc/sudoers
mode of "/etc/sudoers" changed from 0640 (rw-r-----) to 0440 (r--r-----)

この場合、新しいユーザーを使用してログインし、sudoを使用します.
[root@localhost ~]# su linuxidc   

[linuxidc@localhost ~]$ sudo cat /etc/passwd
[sudo] password for linuxidc: 

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.