Passwords 使用Visudo启用无密码sudo命令
我的主目录中有一个名为“rescan.sh”的脚本。我创建了一个指向脚本的符号链接,并将其放置在/usr/local/bin中。该脚本执行以下操作:Passwords 使用Visudo启用无密码sudo命令,passwords,sudo,sudoers,visudo,Passwords,Sudo,Sudoers,Visudo,我的主目录中有一个名为“rescan.sh”的脚本。我创建了一个指向脚本的符号链接,并将其放置在/usr/local/bin中。该脚本执行以下操作: #!/bin/bash sudo sh -c "echo 1 > /sys/bus/pci/rescan" 我需要这个脚本,使我的读卡器正常工作,我需要在每次重新启动后运行这个脚本(长话短说,不同的问题,不要进入这个) 我想要实现的是脚本在启动时自动运行。我需要sudo权限来运行这个脚本,因此我需要一个无密码的sudo来运行这个脚本。我可以
#!/bin/bash
sudo sh -c "echo 1 > /sys/bus/pci/rescan"
我需要这个脚本,使我的读卡器正常工作,我需要在每次重新启动后运行这个脚本(长话短说,不同的问题,不要进入这个)
我想要实现的是脚本在启动时自动运行。我需要sudo权限来运行这个脚本,因此我需要一个无密码的sudo来运行这个脚本。我可以用expect或visudo来实现这一点。由于安全原因,我只考虑后者。我一直在用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 editor=/usr/bin/vim
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%admin ALL=(ALL) NOPASSWD:/usr/local/bin/rescan
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
其他信息:
- 这个系统是我自己的个人笔记本电脑(我是root、sudo等)
- 在64位上运行Linux Mint 13
- 这个问题由来已久,这个答案只是猜测,但
改变
%admin ALL=(ALL) NOPASSWD:/usr/local/bin/rescan
到
也许会有帮助。但是,请注意:我不知道与此相关的安全风险
your_usual_user_name ALL=(ALL) NOPASSWD:/usr/local/bin/rescan