第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > xxx is not in the sudoers file. This incident will be reported.

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

时间:2023-05-14 05:19:41

相关推荐

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

参考链接

如何把普通用户添加到sudoers file/etc/sudoers文件解析

测试环境

操作系统:CentOS

xxx is not in the sudoers file

[ljl@VM-0-8-centos python]$ sudo -s[sudo] password for ljl:ljl is not in the sudoers file. This incident will be reported.

如上所示,普通用户执行“sudo -s”切换到root用户时报错:xxx is not in the sudoers file. This incident will be reported.

根据错误提示,当前用户不在sudoers file,需要将当前用户添加到sudoers file

sudoers file是什么文件?

Sudoers allows particular users to run various commands as the root user, without needing the root password.

sudoer使得普通用户能像root用户一样执行各种命令,而不必使用root密码。

sudoers file默认指的是 文件/etc/sudoers

$ ls -lha /etc/sudoers-r--r----- 1 root root 4.3K Oct 19 14:41 /etc/sudoers

如何把普通用户添加到sudoers file

为了安全起见,/etc/sudoers文件是只读的,必须使用命令visudo来编辑它:

$ visudo --helpvisudo - safely edit the sudoers fileusage: visudo [-chqsV] [-f sudoers]Options:-c, --check check-only mode-f, --file=sudoers specify sudoers file location-h, --helpdisplay help message and exit-q, --quiet less verbose (quiet) syntax error messages-s, --strict strict syntax checking-V, --version display version information and exit

root用户执行visudo,找到 “root ALL=(ALL) ALL” 这行,在下面添加一行:

usernameALL=(ALL) ALL

如果想要在使用“sudo -s”时跳过输入密码,则可以添加一行:

username ALL=(ALL) NOPASSWD:ALL

username是具体的用户名称。

然后Esc退出编辑,最后:X保存并退出。

【完】

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。