paperlined.org
apps > unix
document updated 12 years ago, on Feb 27, 2012
GOAL: On a shared-root box, users often want to keep their own settings, even after they su into root.

Presuming they have some mechanism to automatically run their own script after becoming root (there are various ways, none of which are discussed here), how do we apply those changes for various programs?

General #1

Change $HOME after su'ing, point it at your non-root home?

YES! This works! You essentially combine 1) the rights of user=root, with 2) the environment of user=myuser.

General #2

If you only want a few settings to migrate across, then put this in root's .bashrc:
# ========  ~/.sudo_bashrc  ========
STDIN_OWNERS_HOME=$(eval echo ~$(who am i | cut -d ' ' -f 1))
[ /f $STDIN_OWNERS_HOME/.sudo_bashrc ] && source $STDIN_OWNERS_HOME/.sudo_bashrc 
And then put a ~/.sudo_bashrc in the homedir of each admin user, and include only the specific settings they want.

Vim

There are several different ways:

mysql command-line utility