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've created a Nautilus Action to edit files as sudo (gksudo) and the text editor that opens the file is always using a different configuration from the normal user.

The same thing happen when I run sudo gedit file or sudo subl file

Can I fix this or it's a security measure?

share|improve this question
Sublime text's config files are saved in the user's .config directory (at /home/braindamage/.config/sublime-text-2). When you open Sublime with gksudo, Sublime uses/creates the root's config files at /root/.config/sublime-text-2. I've tried linking and copying my user account's config directory to the root's config location. It pulls in the right config options, but it causes Sublime text to time out. So not a viable solution right now. – d_rail Dec 1 '13 at 2:53
up vote 2 down vote accepted

What happens in your case is that probably the configuration contains the option always_set_home which switches the home directory and thus the configuration to /root.


  • You can use sudoedit for this purpose, which will preserve your environment.
  • You can check your sudo configuration using sudo visudo and comment out the always_set_home option
  • You can use sudo -E gedit file to preserve the environment

I'm not aware of any security implications, but of course nasty things will happen if someone replaces the gedit configuration file with a symlink to a system file. But if you use sudo gedit it is assumed that you know what is going on on your system.

share|improve this answer
Thanks, I'm using gksudo -k now for the launchers and will proceed to use -E on sudo's – braindamage Dec 10 '12 at 15:13

This is because when you run anything as a sudoer you are actually using the sudo profile which has as good as root access for the particular command you ran. So things like the default window size, whether it makes backup copies of files and the like, will all need to be set while running gedit under sudo. (Just go to Edit - Preferences when in gedit as sudo and changes will be saved in the sudo gedit profile.)

share|improve this answer

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.