I have a script called "rescan.sh" somewhere in my home directory. I created a symbolic link to the script and placed it in /usr/local/bin. The script does the following:
#!/bin/bash
sudo sh -c "echo 1 > /sys/bus/pci/rescan"
I need this script to make my card reader work properly and I need to run this script after each reboot (long story, different problem, do not go into this).
What I would like to achieve is that the script is run automatically at start-up. I need sudo rights to run the script and therefore I need a passwordless sudo for this script. I can do this either with expect or with visudo. Due to security reasons I only consider the latter. I have been experimenting with visudo and nothing has worked yet. I would like some assistance with setting this up. Here is my 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
Additional information:
- This system is my own personal laptop (I am root, sudo etc)
- Running Linux Mint 13 Cinnamon 64 bit
This question is ancient and this answer is just a guess but...
changing
to
might help. But, please be warned: I have no idea about the security risks associated with doing this!