1. 程式人生 > >Linux 使用者新增sudo許可權

Linux 使用者新增sudo許可權

本文簡單介紹下在Linux環境下如何建立一個使用者並給此使用者賦予sudo許可權。

1 root建立測試使用者test

[[email protected] ~]# useradd test

2 切換test使用者檢查sudo許可權

[[email protected] ~]# su - test
[[email protected] ~]$ sudo date

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.

3 切換root使用者用visudo新增test使用者sudo許可權

[[email protected] ~]# visudo
通過visudo開啟/etc/sudoers檔案,新增以下行並儲存
test    ALL=(ALL)       NOPASSWD: ALL

4 再次切換test使用者檢查sudo許可權

[[email protected] ~]# su - test
[[email protected] ~]$ sudo date
Fri Oct 28 11:19:57 CST 2016