CentOS sudo prompts the user to use the solution is not in the sudoers file
Method / Step
-
To root
[linux@localhost ~]$ su root
password:
[root@localhost ~]#
-
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
-
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}
-
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
-
切换到普通用户,测试用户权限提升功能