Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Gnome, there is gksudo.

In KDE, there is kdesudo.

Is there a command that can be run on any desktop environment that will prompt the user for the root password and then run a command?

share|improve this question
See also: If you find anything, consider submitting the information to the Freedesktop guys, since it will be generally useful. – Mechanical snail Jan 11 '13 at 18:23

The manpage for the zenity command Manpage icon contains the following description:

zenity is a program that will display GTK+ dialogs, and return (either in the return code, or on standard output) the users input.

As far as I can tell (and my testing backs this up), this will work in both the Gnome and KDE desktop environments. For example:

zenity --password | sudo -S nautilus

...will prompt you for your root password and then launch Nautilus.

share|improve this answer
Wasn't there some reason you were supposed to run graphical programs using gksu/kdesudo rather than sudo though? Something about setting up the proper environment. – Mechanical snail Jan 10 '13 at 6:34
Oh. I see you're discussing it in chat. – Mechanical snail Jan 10 '13 at 6:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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