So, I would like to keep bash
as the default shell for root.
But, I would prefer to use zsh
, my shell, when I run sudo
commands, and that sudo
executes also the .zshrc in /root.
For testing purposes, I have created an alias in my /root/.zshrc
and ~/.zshrc
:
alias test1='echo "Test OK"'
Now, when I run sudo su
enter zsh
enter test1
enter
I got the expected result : Test OK
However, all of these commands result in : test1: command not found
sudo test1
sudo su -c 'zsh -c test1'
sudo -E zsh -c 'test1'
sudo ZDOTDIR=/root/.zshrc test1
sudo ZDOTDIR=/root/.zshrc zsh -c 'test1'
sudo ZDOTDIR=/root/.zshrc zsh -c 'source /root/.zshrc && test1'
I found this question on askubuntu, but I think this is more related to this one on Unix & Linux.
However, none of these posts help me.
What I want to achieve in final is to create a simple alias that could replace sudo
when I want to use zsh
with its /root/.zshrc file, and prefix the command I want to run.
Any hints ?
sudozsh
and use it in the same way ofsudo
).alias sudozsh='sudo zsh -ic'
doesn't work with commands such astail -f /var/log/syslog
. I would like also not having to backslash quotes in commands. – aklmie Aug 14 '15 at 00:14&&
specially, so use your alias, but quote the command to send:sudozsh 'tail -f'
,sudozsh 'cd /remote/dir && tar cf - .' | tar xf -
– glenn jackman Aug 14 '15 at 01:18