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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章