oh my zsh for the root and for all user

Solution 1:

I made symbolic links to my zsh files in my home dir, that seems to work fine:

ln -s $HOME/.oh-my-zsh           /root/.oh-my-zsh
ln -s $HOME/.zshrc               /root/.zshrc

Disclaimer (Updated 2020-3-9): Only do this on a single user machine as it will make a user able to run programs as root (see comment by Eliah Kagan).

Solution 2:

Just run the install command as root user (after doing sudo su)

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Solution 3:

For anyone else with the same question, I would recommend a combination of Tummala Dhanvi's and Morton's approach. I installed oh-my-zsh both as root and as the user using the following commands:

User:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Root:

su
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Then I created a symbolic link for the config file (run as user):

sudo ln -s /root/.zshrc $HOME/.zshrc

Make sure the user has permissions to read the file:

sudo chmod 744 /root/.zshrc

This approach allows for a shared config while keeping the system secure. You will, however, need root privileges to edit .zshrc

Solution 4:

First install zsh or some shell with say oh-my-zsh as a normal user.

If you have normally setup the zsh shell & oh-my-zhs framework, then don't just sudo su into root & type chsh -s $(which zsh) $(whoami) to change shell & framework

First create system links in root of your home shell & framework configs;

  • ln -s $HOME/.zshrc /root/.zshrc
  • ln -s $HOME/.oh-my-zsh /root/.oh-my-zsh

Then after that go on and change the shell chsh -s $(which zsh) $(whoami)

BUT if you already changed the shell before making the system links then you will get a return of probably /root/.zshrc or so file already exists.

There you have to navigate to the source /root & delete whatever existing file they said & then do the system link command required to create it again but sourced from home.

After that you will have a root with the same shell & framework like you have in your normal user's terminal

if you have already done all these & it doesn't work because of permission issues, then just grant the permission to these root files;

  • sudo chmod 744 /root/.zshrc