Linux用户无法使用sudo命令

版权声明:欢迎转载,转载必须标明出处. https://blog.csdn.net/xiaojingfirst/article/details/81747285

新建的用户无法使用sudo命令,出现这样的提示:

xiaojing is not in the sudoers file. This incident will be reported

原来是新建的用户没在sudoers的管理文件中,那往里添加不就完了吗。

1.切换到root用户。

su root #接着系统会提示你输入root用户的密码

2.添加sudoers文件写的权限。

chmod u+w /etc/sudoers

3.编辑sudoers文件并添加相应的内容。

vim /etc/sudoers

找到

# User privilege specification
root ALL=(ALL:ALL) ALL

在下面仿写一句

xiaojing ALL=(ALL:ALL) AL #xiaojing是新建的用户

(注:在vim下,输入请按:i键进入编辑模式,保存:先按ESC键进入命令模式,再输入“:wq”保存退出)

4.撤销sudoers文件的权限。

chmod u-w /etc/sudoers

到此xiaojing可以使用sudo命令了。

猜你喜欢

转载自blog.csdn.net/xiaojingfirst/article/details/81747285