I have a mount script I need to run as admin. Since nobody knows how to run it automatically, I want to at least reduce the pain of manual start. The script has one line:

sudo mount ... more params

When I select execute, nothing happens:

image description

I also tried this answer, no effect. If I run the script from terminal, everything works.


You can use gksudo which is a GTK+ frontend for su/sudo.

sudo asks for the password on the command line, and gksudo pops up a dialog box for it.

Relevant manpage

  • I replaced sudo with gksudo in my script and I still observe nothing. Definitely not a dialog window. – Tomáš Zato - Reinstate Monica Sep 29 '15 at 8:45
  • Well, that's strange. Open a terminal window, type gksudo whoami and tell us what happens. If you haven't configured your user otherwise, a GUI prompt asking your password should pop up. – Jan Sep 29 '15 at 9:18

You could set up a sudo rule such that either all users, some specific users, and/or all members of a particular group can run the script without a password. e.g. in /etc/sudoers:

Cmnd_Alias MYSCRIPT = /usr/local/sbin/mountscript.sh

That allows user cas and all members of group admin to run /usr/local/sbin/mountscript.sh as root without needing to enter a password.

mountscript.sh should be extremely simple. It would be best if it took no arguments and no input at all from the user, and just performed a fixed set of operations (e.g. mount the filesystem in a particular location and then exit)

If required, you could also have an unmountscript.sh set up in sudo in the same way... just add /usr/local/sbin/unmountscript.sh to the end of the Cmnd_Alias definition line.

Finally, your icon on the desktop would either:

  1. run sudo /usr/local/sbin/mountscript.sh or
  2. run a wrapper shell script which did nothing except sudo /usr/local/sbin/mountscript.sh

in both cases, all scripts mentioned should be mdae executable with chmod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.