When I work with the terminal and use su
or sudo
to execute a command with the root user's permissions, is it possible to apply the configuration of my "non-root user" (from which I am invoking su
or sudo
) stored in this user's home directory?
For instance, consider that (being logged on as a non-root user) I would like to edit the configuration file /etc/some_file
using vim
and that my vim configuration file is located at /home/myuser/.vimrc
. Firing up the command line and typing sudo vim /etc/some_file
, I would want "my" beautiful and well-configured vim
to show up. But what I get is an ugly vim
with the default configuration, no plugins etc.
Can I make su
or sudo
use my user's configuration files instead of the root user's files located at /root?
Defaults env_reset
andenv_keep += "HOME"
, thus preserving my$HOME
environment variable. – zepp133 Jul 18 '14 at 10:38