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.
2 Answers 2
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
...
...
cas ALL = NOPASSWD: MYSCRIPT
%admin ALL = NOPASSWD: MYSCRIPT
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:
- run
sudo /usr/local/sbin/mountscript.sh
or - 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
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
withgksudo
in my script and I still observe nothing. Definitely not a dialog window.Tomáš Zato– Tomáš Zato2015年09月29日 08:45:17 +00:00Commented Sep 29, 2015 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– Jan2015年09月29日 09:18:14 +00:00Commented Sep 29, 2015 at 9:18