linux給用戶添加sudo權限

本人用的是ubuntukylin13.10。剛纔想用早上新添加的用戶vinci來新增加用戶,提示沒有sudo權限:

vinci@flymouse-pc:~$ sudo useradd test
[sudo] password for vinci: 
vinci is not in the sudoers file. This incident will be reported.


有時候,linux下面運行sudo命令,會提示類似: 
xxx is not in the sudoers file.  This incident will be reported.
這裏,xxx是用戶名稱,然後導致無法執行sudo命令,這時候,如下解決:


1.進入超級用戶模式。也就是輸入"su -",系統會讓你輸入超級用戶密碼,輸入密碼後就進入了超級用戶模式。

2.添加文件的寫權限。使用以下命令:

root@flymouse-pc:~# chmod u+w /etc/sudoers

3.編輯/etc/sudoers文件。使用以下命令:

root@flymouse-pc:~# gedit /etc/sudoers

找到這一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(這裏的xxx是你的用戶名,我是vinci),然後保存退出。

# User privilege specification
root    ALL=(ALL:ALL) ALL
vinci   ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges

4.撤銷文件的寫權限。使用以下命令:

root@flymouse-pc:~# chmod u-w /etc/sudoers




發佈了34 篇原創文章 · 獲贊 9 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章