命令行执行的crontab 命令,但是需要包含sudo 才可以执行的命令,怎么办呢?见下:

leo@leo-Ubuntu:/etc$ visudo
visudo: /etc/sudoers: 权限不够
visudo: /etc/sudoers: 权限不够
leo@leo-Ubuntu:/etc$ sudo visudo

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bi$

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL:ALL) ALL

#省略。。。

#includedir /etc/sudoers.d
leo ALL=NOPASSWD: /usr/sbin/service squid3 restart
leo ALL=NOPASSWD: /usr/bin/nmcli con up id vpn

格式:

username ALL=NOPASSWD:  yourcommand

参考:

Sudo without password to run dd command Python

Linux服务器的初步配置流程 - 阮一峰的网络日志

最新文章

  1. 教你一招:解决win10/win8.1系统在安装、卸载软件时出现2502、2503错误代码的问题
  2. abrt-hook-ccpp: Saved core dump of pid 12224导致dn挂掉问题
  3. 取得交换机的MAC地址
  4. RCC BUCK-BOOST变压器设计
  5. HttpModule和Http Handler (比较与区别)
  6. 【COM学习】之一、QueryInterface
  7. 移动端app测试
  8. annotation 不给提示
  9. nginx常用命令参数
  10. dubbo实现示例
  11. Vue-Vue组件的注册和使用
  12. 函数和常用模块【day05】:不同目录间进行模块调用(八)
  13. 利用反射创建User类的对象
  14. json解析出来数据为空解决方法
  15. (转载)Rime输入法—鼠须管(Squirrel)词库添加及配置
  16. nodejs抓取别人家的页面的始末
  17. lua 根据函数名字符串来执行函数
  18. 關於 WebClient wc = new WebClient() 下載第三方數據不能進安安信任異常
  19. BZOJ1835: [ZJOI2010]base 基站选址【线段树优化DP】
  20. php—Smarty-缓存1(25)

热门文章

  1. Dom方法,解析XML文件
  2. LeetCode刷题 Flood Fill 洪水填充问题
  3. log4j的log4j.properties文件配置的详细介绍
  4. Struts2的基础知识
  5. 读书笔记 enum枚举之位标志属性(Flags)浅析
  6. Android : apk签名的多种方法以及key的配置
  7. 1076 Wifi密码
  8. alpha通道与混合技术
  9. <Spark><Advanced Programming>
  10. python-web-django前后端交互