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 am kind of lazy. Is there a way to when I click on the sublime text icon for it to automatically run as gksudo?

share|improve this question
For your second question: – Seth Feb 25 '14 at 19:34
@Seth Thanks a lot should've looked for that – inquisitiveIdiot Feb 25 '14 at 19:41
up vote 4 down vote accepted

Sublime Text should have a .desktop file located in /usr/share/applications/ named sublime-text.desktop.

Open it and change the Exec= line to include gksu (or gksudo they are the same) at the beginning.

enter image description here

Now unpin and repin the sublime text icon to the launcher.

NOTE: Your path to the sublime executable will probably be different, that's because I installed the Sublime 3 beta, don't worry about it, just add gksu.

share|improve this answer
I'm using 14.04 and sublime text 3, the file .desktop for sublime now called sublime_text.desktop – rails_id Jun 21 '15 at 16:24
didn't work for me until I realized I didn't have gksu installed. A simple sudo apt-get install gksu took care of that, and now it's working as expected. – Chris Dec 28 '15 at 10:14

gksudo - is graphical sudo. For instance you won`t see Password dialog if you run command "sudo nautilus" using Alt+F2 You may make a script (sh file)

gksudo /usr/bin/<your_app>


chmod +x <your>

And then run it in Nautilus (check option "ask what to do when opening executable files" in settings)

share|improve this answer

Like Seth said, Sublime Text should have a .desktop file located in /usr/share/applications/ named something like sublime-text.desktop.

You can then open it up and change the exec= line to include gksudo at the beginning, so it should now look like this: gksudo <command already there for starting Sublime-text>.

While this will automatically launcher Sublime text with the gksudo window, you will still have to enter your password each time, which isn't what you want.

However, what you want is possible to do, but the only way I can think of would introduce a pretty serious security risk.

You would have to turn off the sudo timeout, which allows basically anything to run as sudo, without your permission, which basically defeats the entire purpose of the sudo password. Check out this question for some possible help with that.

All in all, I know of no way to do what you want entirely safely. If you don't mind risking your system a little, it can be done via turning off the sudo timeout, but I highly recommend against that.

You would still have to enter the sudo password each time you log on, but by turning off the sudo timeout you wouldn't have to enter it again until you logged out or rebooted.

share|improve this answer
I don't mind typing my password in I just want it to automatically run as administrator. Thanks for your help – inquisitiveIdiot Feb 25 '14 at 19:49

I know you asked for every time, people reading this if you want to just launch it once as root try

sudo subl

Do Not Use. See comments.

share|improve this answer
Bad idea - never run GUI apps with plain sudo - it might give you troubles on the next login - see problems with .Xauthority – guntbert Jun 15 '14 at 20:19
Thanks, for correcting me.When I run gksudo subl though sublime text does not launch. – jalbasri Jun 16 '14 at 13:22

I stumbled across this via a Google search. I know this doesn't answer the OP's original question, but it is for anyone that used the same query as I.

The accepted answer didn't work for me. I just ran sublimetext from the command line with gksudo.

gksudo /usr/bin/subl

share|improve this answer
The reason this is incorrect and the accepted answer is correct is because the question is to default the application to run as gksudo. What you wrote will work to run sublime as sudo but it will not default the app to run as sudo when it is opened via icon. – inquisitiveIdiot Apr 26 at 19:40

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.