7

I tried changing it the way recommended in How do I change my default shell on a AWS instance?, as shown below:

chsh -s $(which zsh)

but that gave me an error. The system asks me to use ypchsh instead, but that gives me this error message:

ypchsh: can't get local yp domain: Local domain name not set

What can I do to set my remote shell to zsh?

2
  • 1
    That sounds as if the yellow page service (yp) is not properly configurated... a ugly workaround (also in case zsh is not listed in /etc/shells -- perhaps you can check this, too) is to include exec /bin/zsh in the .profile file (or whatever file will be read by the default shell).
    – mpy
    Mar 3, 2013 at 10:14
  • I have a different use case. I want to change to a specific shell on a particular server. I searched around quite a bit until I found this question. Thank you!
    – Haozhun
    Aug 28, 2015 at 1:50

1 Answer 1

5

You could contact the system administrator and ask if that is supposed to be supported, and if so for him/her to fix it.

What I do in a cluster where changing the shell to zsh is not supported is this (inside my ~/.bashrc):

# if this is an interactive shell
if [[ $- == *i* ]]; then
  # if on one of those annoying hosts...
  if [[ `uname -n` == PATTERN_MATCHING_SOME_HOSTNAMES ]]; then
     # if there is actually a zsh command available
     if [[ -x `which --skip-alias zsh 2>/dev/null` ]]; then
        # avoid spawning zsh every time bash is started...
        if [ -z $ZSH_STARTED ]; then
            export ZSH_STARTED="true"
            # if the call to zsh fails, scp a different conf there
            exec zsh
        fi
     fi
  fi
fi
4
  • 2
    This is basically what I meant in my comment above. Two remarks: (i.) You can very often compile zsh in your home directory (few dependecies), so you don't have to use some (ancient) version which is installed by chance. (ii.) change zsh in your code to exec zsh and gone is the disadvantage that you need to log out twice!
    – mpy
    Mar 4, 2013 at 19:08
  • edited the answer including the exec...
    – Francisco
    Mar 5, 2013 at 17:24
  • I haven't 100% tested, but I think .bashrc is only sourced on interactive shells. The test for interactive shell won't hurt, but in theory it isn't needed. (ksh needs the test though, which I've found out the hard way) Mar 5, 2013 at 17:41
  • 1
    IIRC many Linux distro's will source .bashrc from .profile thus it may get executed also for non-interactive shells.
    – Francisco
    Mar 5, 2013 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .