0

I have modified my .zshrc and .vimrc to my likings. Both files source other files containing more configuration and plugins (vundle, antibody). Now I would like to use these configurations when I change to the root user as well.

Currently my .zshrc looks like this

# .zshrc
# Sources the files in .shell directory
export SHELL_CONF_DIR='/home/myUser/.shell'
source $SHELL_CONF_DIR/initShell.sh

initShell.sh does the following

# initShell.sh
# Sources further scripts
. $SHELL_CONF_DIR/antibody.sh
. $SHELL_CONF_DIR/compinstall.sh
. $SHELL_CONF_DIR/configuration.sh
. $SHELL_CONF_DIR/options.sh
. $SHELL_CONF_DIR/aliases.sh
. $SHELL_CONF_DIR/variables.sh
. $SHELL_CONF_DIR/virtualenv.sh
. $SHELL_CONF_DIR/functions.sh
. $SHELL_CONF_DIR/keybindings.sh
. $SHELL_CONF_DIR/xorg.sh

I want to manage my .vimrc in a similar fashion.

Now the root users .zshrc is just a symlink to my normal users .zshrc. This works pretty well but I think, concerning security, this might not be an ideal solution. So where should I actually put all this configuration and how should I handle it so the root user can use it, too? Or is this actually the wrong approach?

I know that I can preserve environment variables with sudo -E but that doesn't work when doing sudo -i.

  • Since root has access to the whole file system anyway you could just leave the files where they are and source them from root's profile. – jesse_b Aug 4 '17 at 11:20
  • I don't necessarily see a security issue with your symlink though, however it may become a problem if you want something to load for root in the future that should not be loaded for the user, in which case sourcing your user profiles at the bottom of root's profiles should do that. – jesse_b Aug 4 '17 at 11:22
  • Okay, so this is would not a concern? EDIT: Okay, thank you – herhuf Aug 4 '17 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.