Question

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!

Was it helpful?

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.

OTHER TIPS

Never use sudo to start graphical applications as root, you run the risk of allowing the files in your ~HOME directory becoming owned by root.

Running gksu is almost identical to running sudo -i in which case the ~HOME environment variable is switched to root (hence the root/etc/etc)

Try using gksudo instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top