Sudo prompts the user to use the solution is not in the sudoers file

CentOS sudo prompts the user to use the solution is not in the sudoers file

Method / Step

  1. 1

    To root

    [linux@localhost ~]$ su root

    password:

    [root@localhost ~]#

  2. 2

    Check / etc / sudoers file permissions, if the read-only access, modify writable permissions

     [root@localhost ~]# ll /etc/sudoers

    -r--r-----. 1  root root 4030 12月  10 09:55 /etc/sudoers

     [root@localhost ~]#  chmod 777 /etc/sudoers

    [root@localhost ~]# ls -l /etc/sudoers

    -rwxrwxrwx. 1 root root 4030 12月  10 09:57 /etc/sudoers

  3. 3

    Modify / etc / sudoers file, execute the following command:

    / * Username is your user name * /

    [root@localhost ~]# echo 'username  ALL=(ALL)    ALL' >> /etc/sudoers  

    Visudo input or the root authority or vim / etc / sudoers, find root ALL = (ALL) ALL field, the next line is added:

    username    ALL=(ALL)     ALL

    After 5 minutes the password expires, next time you need to re-enter, so you do not want trouble, you can use the following method

    username    ALL=(ALL)     NOPASSWD: ALL

    Description: the format {username = command network host range (target user executing the command) executed}

  4. 4

    Save and exit, and restore the / etc / sudoers access to 440

    [root@localhost ~]# chmod 440 /etc/sudoers

    [root@localhost ~]# ll /etc/sudoers

    -r--r-----. 1 root root 4030 12月  10 09:59 /etc/sudoers

  5. 5

    切换到普通用户,测试用户权限提升功能 

发布了18 篇原创文章 · 获赞 4 · 访问量 2万+

Guess you like

Origin blog.csdn.net/ostriches/article/details/51178446