I run ubuntu-12.04 desktop x86_64. I have a simple script that needs to be accessible from the Desktop and run as root:

$ cat ~/Desktop/flash.sh
#!/bin/bash -

cd ~/tools
sudo ~/tools/fastboot-HW.sh

I've read how to run sudo command with no password and sudoers simple explanation and safely execute custom script-parts as sudo (on serverfault) also. I modified my /etc/sudoers as follows:

$ sudo cat sudoers
Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# User privilege specification
root    ALL=(ALL:ALL) ALL
root    ALL=(ALL) NOPASSWD:/home/john/Desktop/flash.sh
john    ALL=(ALL) NOPASSWD:/home/john/Desktop/flash.sh
root    ALL=(ALL) NOPASSWD:/home/john/tools/fastboot-HW.sh
john    ALL=(ALL) NOPASSWD:/home/john/tools/fastboot-HW-sh

My sudo-capable user is john. He is member of group:

john adm cdrom sudo dip plugdev lpadmin sambashare

My scripts are fully executable:

$ ls -al ~/Desktop/
-rwxr-xr-x  1 john john  129 Feb 13 17:16 flash.sh
$ ls -al ~/tools/
-rwxrwxr-x  1 john john   17251 Feb 13 17:15 fastboot-HW.sh

When double-clicking on flash.sh icon on my desktop, and selecting "run in terminal", system still prompts for a passwd. John's passwd is not empty, I'd like to keep it not empty. I also tried to push my 2 scripts to /usr/local/bin and adapt /etc/sudoers accordingly, but no luck. What I missed must be really obvious, but I cannot find it.

  • Take a look at this question and comment if it worked for you.
    – Lucio
    Feb 14, 2013 at 17:43
  • @Lucio the python example script works for me on ubuntu-11.10. Need to check my real script on the ubuntu-12.04 machine.
    – m-ric
    Feb 23, 2013 at 15:18


Browse other questions tagged or ask your own question.