Home > Back-end >  How to Change my default shell on server?
How to Change my default shell on server?

Time:03-15

I was assigned an account for log in to a remote server, and I want to change my default shell.

I tried chsh command but it says: chsh: "/public/home/{my_id}/bin/zsh" is not listed in /etc/shells.

CodePudding user response:

  1. First check all the shells available on your linux system
cat /etc/shells
  1. Use chsh command line utility for changing a login shell with the -s or –shell option like this.
# chsh --shell /bin/sh tecmint

CodePudding user response:

If you don't have permission to install zsh system wide, a quick fix is to append exec ~/bin/zsh -l to ~/.bash_profile (if bash is the current shell), or an equivalent rc file for the current login shell.

  • zsh -l starts zsh as a login shell.
  • exec COMMAND replaces the current process with COMMAND, so you'll only have to type exit (or press ctrl d) once.
  • ~/.bash_profile is executed when bash starts as a login shell, you can still run command bash normally.

Depending what is in ~/.bash_profile (or equivalent), you may wish to avoid executing its other contents, by putting exec ~/bin/zsh -l at the start of the file (not the end), and copy/port anything important over to the zsh equivalent, $ZDOTDIR/.zprofile.

I might also do export SHELL="$HOME/bin/zsh", although I'm unsure of the full effects of setting SHELL differently to that specified for your user in /etc/passwd, to a shell not in /etc/shells, and to a shell binary in your home path.

  • Related