I run zsh on Mac OSX, and sometimes want to switch in the terminal to the root user.
I'd like to keep all my dotfiles, and environment path configuration and scripts from my regular user, and just do lots of stuff as root.
I've been running sudo bash
or sudo zsh
as my easy way to switch to root, but this has the disadvantage of not running all my zsh config I have for my regular user.
What's the best way to "become root" for running a series of commands, and keep all the config/environment setup I have for my normal user?"
For example, I have customized the following for my normal user, and would like to have them all available to the root user, as well:
- .zshrc
- ~/bin
- .aliases
- vim mode for input
EDIT: Note that I am aware that I shouldn't "run as root" a lot. And I don't. But I do have to constantly run a few simple commands as root at times, and I open a tmux split just for this usage, and no other.
/root/.zshrc -> /your/user's/home/.zshrc
, you'd always be up to the latest changes. Alternatively change root's home dir to your user's. – FelixJN Feb 15 '16 at 14:04sudo bash
orsudo zsh
your calling a shell. That new shell will override some of the old shells "stuff", but you can check the man pages to see if there is a way to limit what variables it overrides. – coteyr Feb 15 '16 at 14:17