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

ikevin8me

Active Member

Reaction score: 12
Messages: 198

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!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,740
Messages: 39,332

Set the path in root's (from the jail) ~/.cshrc. For zsh you can use ~/.profile for example.
 
OP
I

ikevin8me

Active Member

Reaction score: 12
Messages: 198

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?
 
OP
I

ikevin8me

Active Member

Reaction score: 12
Messages: 198

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.
 

vigole

Daemon

Reaction score: 1,562
Messages: 1,393

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.
 
OP
I

ikevin8me

Active Member

Reaction score: 12
Messages: 198

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.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,740
Messages: 39,332

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.
 

olli@

Daemon
Developer

Reaction score: 1,262
Messages: 1,140

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.
 
Top