I execute chsh -s $(which zsh) but bash stay my default shell, why?

Hi,

I want to set zsh as the default shell.

I have already executed:

$ chsh -l
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/usr/bin/tmux
/bin/tmux
/usr/bin/zsh
/bin/zsh
$ chsh -s $(which zsh)
Changing shell for stephane.
chsh: Shell not changed.
$ cat /etc/passwd | grep "stephane"
stephane:x:1000:1000:stephane:/home/stephane:/usr/bin/zsh
$ echo $SHELL
/bin/bash

I don’t understand why bash stay my default shell :thinking:

Do you have any idea how I can correct this?

I see also this resources:

Best regards,
Stéphane

[stephane@MiWiFi-R4A-srv ~]$ neofetch 
...
OS: Fedora Linux 35 (Workstation Edition) x86_64 
Kernel: 5.15.14-200.fc35.x86_64 
Packages: 1979 (rpm), 24 (flatpak) 
Shell: bash 5.1.8 
DE: GNOME 41.3 
WM: Mutter 
...                              

Have you logged out and logged back in? Otherwise the shell change won’t have taken effect.

If you have tried that and it still isn’t working, make sure you aren’t explicitly setting a shell in your terminal settings.

If you want to switch the running shell to zsh(as opposed to the default shell), you can use exec zsh

Yes, many times, even many reboot.

I just checked, nothing in .zhrc and when I run zsh, I am well under zsh.

I don’t quite understand this comment, it doesn’t correct the error, does it?

Not in .zshrc, in your terminal program. For example, if you gnome terminal, you can set a shell in the settings there. If that is set to bash, it won’t matter what your default shell is set to.

1 Like

Shell to execute is not configure in gnome-terminal settings.

I tested with Alacritty and xterm, same result, default shell is bash :cry:

Hello @stephaneklein ,
merely edit your /etc/passwd file to specify the chosen shell, this is mine …

ssnow:x:1000:1000:Stephen Snow:/var/home/ssnow:/bin/fish

Of course you must use sudo with the editor, so in a terminal sudo edit /etc/passwd should do it.

@jakfrost I have that :

stephane:x:1000:1000:stephane:/home/stephane:/usr/bin/zsh

Can we see the contents of your .zshrc

% cat ~/.zshrc
#
# .zshrc is sourced in interactive shells.
# It should contain commands to set up aliases,
# functions, options, key bindings, etc.
#

autoload -U compinit
compinit

#allow tab completion in the middle of a word
setopt COMPLETE_IN_WORD

## keep background processes at full speed
#setopt NOBGNICE
## restart running processes on exit
#setopt HUP

## history
#setopt APPEND_HISTORY
## for sharing history between zsh processes
#setopt INC_APPEND_HISTORY
#setopt SHARE_HISTORY

## never ever beep ever
#setopt NO_BEEP

## automatically decide when to page a list of completions
#LISTMAX=0

## disable mail checking
#MAILCHECK=0

# autoload -U colors
#colors

Note: same issue with fresh new user (I configured default shell with chsh -s /usr/bin/zsh).

sudo usermod --shell /path/to/shell < user >
or
sudo lchsh < user >

Not sure if it help. Usually I just go to Gnome Terminal setting. On the left list, select the profile then on the top right tab, select “Command”. Select “Run a custom command instead of my shell” then type zsh and reopen the terminal.

Thanks, I know, but this not fix really the issue, I would like default zsh everywhere: alacritty

Incase you missed to try what @grumpey suggested above.

If it not work, may be you also want to try by creating clean new user and change the default shell again in case something in dot file preventing to change the shell default. After that logout and login again.

How was zsh installed?. On my default fedora 35 workstation install zsh is not installed. It seems possible something needed for zsh to work is not installed thus the shell does not activate.

If it makes any difference I note you appear to be on silverblue so that could be a factor as well.

1 Like

In such a case, please refer to this thread:

However, it does not look like it’s Silverblue in the OP’s case since chsh is not installed in Silverblue (by default) the last time I checked.

This thread is tagged as feodra-linux-35 & silverblue and the OP has not said which is actually in use. I guessed at the most restrictive, and noted that fedora 35 workstation does not install zsh by default.

Hello Stéphane,
I’m not sure that you are having the same problem that I did, but please see my reply to this question:

Tom

I have tested with both commands presented by @grumpey, on my Silverblue system, and they both change my default shell as I intend. The only other thing I could note is that if you don’t specify a user for the lchsh command it defaults to the root user and will assign the default for that (usually /bin/bash). Another thing of note may be that your install of ZSH is somehow broken, when you layered it onto Silverblue, were there errors given at the time?