当前位置:   article > 正文

sudo 执行报错centos is not in the sudoers file. This incident will be reported._password for centos

password for centos

执行sudo -i,提示如下信息

[centos@localhost ~]$ sudo -i
[sudo] password for centos: 
centos is not in the sudoers file.  This incident will be reported.

1.执行su,输入当前登录的用户密码,密码不可见,直接输入按回车

  1. [centos@localhost ~]$ su
  2. Password: 

2.进入目录 cd /etc/sudoers,如果找不到,执行命令 chmod u+w /etc/sudoers,接下来编辑文件

vi /etc/sudoers

  1. [root@localhost centos]# cd /etc/sudoers
  2. bash: cd: /etc/sudoers: Not a directory
  3. [root@localhost centos]# chmod u+w /etc/sudoers
  4. [root@localhost centos]# vi /etc/sudoers

3.找到root    ALL=(ALL)       ALL

        Tips

                1.查找字符串:/root  回车,就可以查找root关键字的文本,按“n”查找下一个,按“p” 查找上一个;

                2.输入文本,按“i

                3.保存“:wq

在下面一行加入一下任意行,username 为当前用户名

username ALL=(ALL) ALL
%username ALL=(ALL) ALL
username ALL=(ALL) NOPASSWD: ALL
%username ALL=(ALL) NOPASSWD: ALL

第一行:允许用户youuser执行sudo命令(需要输入密码).
第二行:允许用户组youuser里面的用户执行sudo命令(需要输入密码).
第三行:允许用户youuser执行sudo命令,并且在执行的时候不输入密码.
第四行:允许用户组youuser里面的用户执行sudo命令,并且在执行的时候不输入密码.

4.再次执行  sudo -i 就成功了


 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号