I have installed zsh
and I am using Oh My ZSH plugins. Everything works fine, but when I become a root user, it changes to the default zsh theme.
What should I do to make the Oh My ZSH configuration as the default zsh
for all users including root
?
I have tried using the chsh -s /bin/zsh root
That gave me zsh
but not oh_my_zsh
I also tried cp -R /home/user/.zshrc /root/.zshrc
ing to get oh_my_zsh
for root, but nothing worked.
(I don't need zsh
but I need oh_my_zsh
for all the user in the system)
I made symbolic links to my zsh files in my home dir, that seems to work fine:
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).
Just run the install command as root user (after doing sudo su)
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:
Root:
Then I created a symbolic link for the config file (run as user):
Make sure the user has permissions to read the file:
This approach allows for a shared config while keeping the system secure. You will, however, need root privileges to edit .zshrc
First install
zsh
or some shell with sayoh-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 & typechsh -s $(which zsh) $(whoami)
to change shell & frameworkFirst 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
I installed oh-my-zsh with root account. Now I login with another account, and install oh-my-zsh again in the home directory of the account. It works for the non-root account.
I wrote a short script based on Lord Lulent solution, which works well for me
This might help with this use case https://stackoverflow.com/a/42193058/1408600
You could just install for the intended user using:
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh
su $USER ./install.sh
Yes, it is possible to install OhMyZsh for different users.
If it is ok for you to have completely separated settings, you can provide different ZSH paths for each install, like this:
Cheers!