3

I've created a Nautilus Action to edit files with 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 is it a security measure?

1
  • 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, 2013 at 2:53

2 Answers 2

2

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.

Solutions:

  • 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.

1
  • 1
    Thanks, I'm using gksudo -k now for the launchers and will proceed to use -E on sudo's Dec 10, 2012 at 15:13
0

This is because when you run anything with sudo you are running it as root, so your local profile/config is not applied. Things like the default window size, whether it makes backup copies of files and the like, will all be different. You can make changes to the configuration while running as root, and they will not apply to your normal user, only to root.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .