配置普通用戶具有root權限,從而可以使用sudo命令,使普通用戶暫時擁有root權限。
修改配置文件
(必須用root用戶登錄)
1、打開/etc/sudoers文件
vim /etc/sudoers
2、修改文件
在此處:即root用戶的下面添加,username爲普通用戶的用戶名
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
username ALL=(ALL) ALL
3、修改優化
上面的配置,每次普通用戶使用sudo命令時都會要輸入密碼。
但是如果這樣配置:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
username ALL=(ALL) NOPASSWD:ALL
就不用輸入密碼啦!
4、實例測試:
[username@localhost Desktop]$ sudo vim /etc/sudoers
輸入此命令後如果不報錯,直接進入文件中,說明配置成功。
搞定!!