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

I wrote a custom .desktop file that contains an Exec line

#!/usr/bin/env xdg-open
[Desktop Entry]
Exec=gksudo /my/path/to/

This script launches some zenity calls.

Then I made this desktop file to appear in unity-2d launcher side bar.

My problem is every time I use this launcher shortcut it keeps asking for my password... While the expected behavior is to ask once, then remember for some time. It was acting like that in gnome/Lucid so something has changed but what ?

(I also tried '-k' option but doesn't change my problem)

If try that command line from a terminal (as my regular user)

gksudo /my/path/to/

It works like expected (=same behavior as in Lucid): asks the password only on the first launch.

What am I missing here?

share|improve this question

As far as I know, it is the terminal environment which remembers the password for a certain amount of time.

For example, the command

gksudo nautilus

in the terminal will ask the password only once in a certain timeframe. While the same command in the alt+f2 launcher asks it every time.

Either way, if you want to run something as root, it is not that weird it will ask your password every time. That way you know you will be running the command as root.

share|improve this answer
You're right it is not that weird, but in Lucid, I had the same .desktop file and a different behavior: the password got remembered like any other app that needs administrative privileges (ie: synaptic...). – martin-mystere Nov 29 '12 at 15:35

This is absolutely normal. In the terminal, you've always got the same "session", so it remembers the authentification, but that's not the same with a .desktop launcher.

I'd recommend you to just add a file to /etc/sudoers.d (name it my_script or something like that), so that you can always use your command without password (if your script doesn't accept arguments that should be safe) - but do this at your own risk:

Create a new file with following content

your_username ALL=(ALL) NOPASSWD: /my/path/to/

When I tested it with gksu it worked directly afterwards, but if it doesn't, try logging in and out again or rebooting.

share|improve this answer
I don't want to disable password checking, I just wanna get the elevated privilege remembered like for any other synaptic etc. It was working great in Lucid but something has changed in Precise. It's not a big deal but I wanna understand what has changed :) Thanks anyway ! – martin-mystere Nov 29 '12 at 15:38

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.