Ubuntu 16使sudo不用密码

场景:某个脚本中含有 sudo ...的命令,用户登录后会自动执行此脚本
方法:

  1. 新建文件
    1
    2
    cd /etc/sudoers.d
    touch nopasswd4sudo
  2. vi nopasswd4sudo,添加以下内容
    1
    username ALL=(ALL) NOPASSWD : ALL