View Full Version : Double-click launch a bash script with sudo

January 7th, 2011, 06:38 PM

I am writing a bash script to automate the installation of packages when I configure a new computer. The script is working, but since many of the commands need root privileges, I have to run the script from the terminal, ie "sudo /home/username/Desktop/script.sh". If I double click the script icon on the Desktop, the program runs but fails quickly because it does not have root privileges.

Is there a way to gain root privileges after clicking the script icon?

January 7th, 2011, 07:58 PM
Have the script use sudo.

January 7th, 2011, 08:04 PM
you probably want gksudo not sudo for a gui password prompt.