0

I just installed ZSH on a remote server where we are 2 "admins". I switched my default shell to ZSH with chsh -s $(which zsh). echo $SHELL gives the output /usr/bin/zsh which proves it. But, when I open my ssh session I receive an error like:

/etc/profile.d/vk.sh:30: command not found: shopt

This error appears only at startup and I see it only once when opening an ssh session.

In my understanding, the other admin placed some custom script with his own aliases and using shopt -s histappend command there as well.

My question is, why my SSH ZSH session invoking that script at startup? Shouldn't it be scoped just to my profile?

What would be a graceful solution for me to run ZSH without affecting/touching his stuff? Should I ask him to move that thing somewhere else in his home dir?

1
  • 1
    Hmm... AFAIK /etc/profile (and scripts it sources in /etc/profile.d) really ought to be POSIX/Bourne compatible, for exactly this reason. OTOH I thought zsh should use its own /etc/zsh/zprofile over /etc/profile anyhow? One old-school workaround you could consider is changing your actual login shell to bash and then exec /usr/bin/zsh at the end of your own ~/.profile (or ~/.bash_profile, if you have one). Feb 29 '20 at 19:01
2

The /etc/profile file contains system wide profile settings. Within that file, many distributions are sourcing scripts within /etc/profile.d. Hence, all interactive logins will invoke what is in that folder. If you want a profile script to be scoped to one account, you have to either

  1. move that script into ~/.profile or ~/.bash_profile (for bash users), or

  2. add login in the vk.sh to skip execution based on the logged in user.

2
  • Yes, i think the correct way is to ask him to move his scripts somewhere upstream. ~/.profile IMHO is a good place to put that.
    – Dzintars
    Feb 29 '20 at 19:32
  • 1
    Just remember that ~/.profile is not sourced by bash if ~/.bash_profile exists. It's a peculiarity of bash where it has a built-in preference for its own (i.e. .bash_profile) over posix (.profile) for its environment setup files.
    – Iyad K
    Feb 29 '20 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.