Sunday, February 15, 2009

How to run gnome scripts as root?

You probably are already aware of $HOME/.gnome2/nautilus-scripts/ directory..
You could copy any script here with executable permissions and this will enable the "Scripts" label on the right-click menu and the scripts available will be listed in the sub-menu.
Say, you have a script that needs elevated* privileges, but do not want to open up a terminal to type in the password, but want to open up the fancy dialog that blocks everything and just allows you to type in the "sudo" password.
You could use the 'gksudo' command to accomplish this task
My Scripts menu features a script "Terminal (as root)", which allows me to open a terminal with elevated privileges.

#!/bin/sh
gksu gnome-terminal
exit 0

There you go...now you will also be able to launch the UI dialog that allows you to type-in the sudo password as shown in the image here





WARNING: Running applications with elevated privileges is risky. You better know what you are doing.

No comments: