junq@wode008:~$ sudo /opt/script/ntp.date.sh
[sudo] password for junq:
Sorry, try again.
[sudo] password for junq:
junq is not in the sudoers file. This incident will be reported.
junq@wode008:~$
***是你当前的用户名,原因是***用户没有加入到sudo的配置文件里
// 查看sudo user
root@wode008:/etc/sudoers.d# ls -al /etc/sudoers
-r--r----- 1 root root 745 Feb 11 2014 /etc/sudoers
root@wode008:/etc/sudoers.d#
// 给予写权限
root@wode008:/etc/sudoers.d# chmod a+w /etc/sudoers
root@wode008:/etc/sudoers.d# ls -al /etc/sudoers
-rw-rw--w- 1 root root 745 Feb 11 2014 /etc/sudoers
root@wode008:/etc/sudoers.d#
// 修改内容
root@wode008:/etc/sudoers.d# vi /etc/sudoers
root@wode008:/etc/sudoers.d#
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
junq ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
// 去掉写权限
root@wode008:/etc/sudoers.d# ls -al /etc/sudoers
-rw-rw--w- 1 root root 764 Jul 7 20:52 /etc/sudoers
root@wode008:/etc/sudoers.d# chmod a-w /etc/sudoers
root@wode008:/etc/sudoers.d# ls -al /etc/sudoers
-r--r----- 1 root root 764 Jul 7 20:52 /etc/sudoers
root@wode008:/etc/sudoers.d#
// 普通用户,以sudo执行
junq@wode008:~$ sudo /opt/script/ntp.date.sh
[sudo] password for junq:
7 Jul 20:53:42 ntpdate[9784]: step time server 202.118.1.81 offset -0.681162 sec
7 Jul 20:53:49 ntpdate[9785]: adjust time server 128.138.141.172 offset -0.014033 sec
junq@wode008:~$
【Ubuntu 14.04】*** is not in the sudoers file
原文地址:http://huangchao.blog.51cto.com/10446378/1671816