Wouldn’t normally do this, or recommend it, but for occasional and considered use this is a useful tip.You need to run a program normally requiring sudo, but as a normal user. The usual way of fixing this is to put a line in /etc/sudoers, but you still need to type sudo.The problem I had was with a custom iso I have been putting together. because my WM was openbox I was using a bash script with zenity to provide reboot and shutdown. This was all set up fine, but on installing the distro from the live cd, the installation needed to add a line to the bottom of /etc/sudoers, thereby negating my previously entered line.A long trawl through google provided an answer on ubuntuforums, which was to change the set uid bit for the shutdown command, so that all users could run shutdown with needing sudo. As you can see, doing this to a more important command would create security holes, but in this instance there is not much a hacker can do with shutdown, other than shutdown…AFAIK !!So here is the command I used:
sudo chmod a+s /sbin/shutdown
which gives the following permission:
645 -rwsr-sr-x 1 root root 46864 2011-01-22 01:58 shutdown
I edited out the sudo shutdown in my script and replaced it with /sbin/shutdown and all is well.
There is another way to do this, perhaps best done inside a bash script:
echo "yourpassword" | sudo -S "program"
This works well in most cases.