jails How do I "setenv PATH" in a jail, preferably using zsh?

If I execute the command:
setenv PATH "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/root/.cargo/bin"
after going into the jail by "jexec 1", it would work. However, I'd like to make it sticky. I tried many ways but nothing works.

Further, preferably, I'd like to do the same in zsh, so that by "jexec 1 zsh" could have that path set. How can I do that?

Thanks!
 
Set the path in root's (from the jail) ~/.cshrc. For zsh you can use ~/.profile for example.
 
Alright, I added "setenv PATH "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/root/.cargo/bin"" to ~/.cshrc and it WORKED.

However, I'm still stuck with with .zprofile. I'd like to get this problem resolved with ZSH as well.
If I execute "export PATH="$HOME/.cargo/bin:$PATH" on the command line, it works.
If I place the same "export PATH="$HOME/.cargo/bin:$PATH" in .zprofile, it does NOT work.
What should I place in .zprofile?
 
I just noticed that you say ".profile" (without the z) not ".zprofile". Is that a typo?
I have also just tried setting "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin:~/.cargo/bin" in .profile (without the z).
It didn't work either.
 
I just noticed that you say ".profile" (without the z) not ".zprofile". Is that a typo?

zsh(1) in sh and ksh compatibility modes:
  • Zsh tries to emulate sh or ksh when it is invoked as sh or ksh respectively
  • Login shells source /etc/profile followed by $HOME/.profile.
 
I tried setting /etc/profile and $HOME/.profile and it (zsh) didn't work. Anyway, i think I'll just live by with the default csh.
 
Note that there is a difference in which startup scripts are run when using login and/or interactive shells. A jexec 1 zsh is not a login shell.
 
You should put it into ~/.zshrc which is sourced for every interactive shell, no matter if it’s a login shell or not.
(I assume you’re running zsh in native zsh mode, which is the default, not in sh or ksh compatibility modes.)
See the section “STARTUP/SHUTDOWN FILES” in the zsh(1) manual page for details.
 
Back
Top