How to use sudo in a bash script?

Eamonn Sullivan eamonn.sullivan at
Thu Oct 6 15:19:01 UTC 2005

On 06/10/05, Chris Dunn <chris at> wrote:
> >> 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.

Are you trying to run this in an account with sudo privileges? By
default, that's the account you created during installation. If not,
you'll have to add that account in sudoers. Check the man pages (I'm
not in front of Ubuntu right now).


More information about the ubuntu-users mailing list