How to use sudo in a bash script?

Chris Dunn chris at
Thu Oct 6 15:03:23 UTC 2005

>> For instance I want to include :
>> sudo synaptic
>> in a script to put on a button in the task bar.

> If you want it to run graphically, you need gksudo instead of sudo.

Thanks for the two responses suggesting gksudo. This takes me a stage
further. I now have :

gksudo usr/sbin/synaptic

in the script.

Sure enough this opens a window to enter a password, but then synaptic
does not run after the correct password is entered.

gksudo -u <username> usr/sbin/synaptic gives the same result.

More enlightenment please.

Chris Dunn

More information about the ubuntu-users mailing list