sublimetext2ubuntu-12.04sudogksudo

Ubuntu 12.04 - Use sudo or gksu for launching Sublime text 2?


I am new to using Ubuntu 12.04 and noticed two different ways of launching Sublime Text 2 via Terminal window, first being sudo and the other being gksu.

Upon using both I noticed it's launching different instances of Sublime Text 2 with different instances of files loaded that I've opened on both including saving snippets. Launching with gksu saves the snippets into root/etc/etc and sudo saves them into the home/user/etc/etc.

What is the preferable way to launch Sublime Text 2 in the terminal window? Sudo or gksu and why?

Thanks for the input!


Solution

  • I don't know about Sublime Text in particular, but in general, it is bad form to run an editor as the superuser; it will either use the settings of the superuser (okay, but you probably want your customizations) or it will put the files in your home directory, not owned by you (so if you ever want to use your editor as yourself again, you might not be able to change any preferences).

    Typically, if you need to edit a file that only root can write to, you should be using sudoedit, which will copy the file to a file you can edit, run the editor as yourself, and then copy the changes back. And if you need to edit a file that you don't need to be the superuser to write to, even sudoedit is not necessary: just run the editor directly!


    Addendum

    This is a general principle: only run with the permissions strictly necessary. Judging from your other question, you've been running lots of things with sudo and friends. That's not a good habit to get into: the more things you use sudo with, the more things become owned by root and therefore require you to use sudo again. A vicious cycle. To set things straight again, you may want to set yourself as the owner:

    sudo chown -R `whoami` path/to/directory
    

    While you might not want to do this on system files, almost everything in your home directory should be owned by you. When the permissions are right, you should find you almost never have to use sudo.