Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
1  
For your second question: askubuntu.com/q/11760/44179 –  Seth Feb 25 at 19:34
    
@Seth Thanks a lot should've looked for that –  inquisitiveIdiot Feb 25 at 19:41

4 Answers 4

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

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 at 19:49
1  
@inquisitiveIdiot Then you should follow Seth's instructions. I was just alerting you to a way to automate it, even at a risk to security. Glad to hear you're not so lazy as to introduce an insecure system to the world :D –  RPi Awesomeness Feb 25 at 19:50

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)

#!/bin/bash
gksudo /usr/bin/<your_app>

Then

chmod +x <your scrypt.sh>

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

share|improve this answer

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 at 20:19
    
    
Thanks, for correcting me.When I run gksudo subl though sublime text does not launch. –  jalbasri Jun 16 at 13:22

Your Answer

 
discard

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.