centos普通用戶設(shè)置sudo權(quán)限
在root用戶下創(chuàng)建一個(gè)普通測(cè)試用戶test,切換到test用戶,執(zhí)行mkdir或者rm -rf
會(huì)出現(xiàn)Permission denied,錯(cuò)誤原因是:該用戶暫沒有root權(quán)限
[test@iZ2513wqj05Z app]$ mkdir testmkdir: cannot create directory test? Permission denied
[test@iZ2513wqj05Z app]$
解決辦法:
1:切換到root用戶
[test@iZ2513wqj05Z app]$ su rootPassword: [root@iZ2513wqj05Z app]#
2 :賦予普通用戶root權(quán)限
編輯/etc/sudoers配置文件,找到下面一行,在root下面添加一行,如下所示: root ALL=(ALL) ALL test ALL=(ALL) ALL 修改完畢,現(xiàn)在可以用test帳號(hào)登錄,然后用命令 su - ,即可獲得root權(quán)限進(jìn)行操作。
3:退出root用戶
[root@iZ2513wqj05Z app]# exitexit
[test@iZ2513wqj05Z app]$
4:執(zhí)行l(wèi)inux命令:sudo mkdir test
[test@iZ2513wqj05Z app]$ sudo mkdir test
[sudo] password for test: [test@iZ2513wqj05Z app]$ ll
total 267596drwxr-xr-x 2 root root 4096 Feb 17 17:14 test