How to change the default shell in fedora silverblue?

How to change the default shell in fedora silverblue ?
I want to change zsh as my default shell instead of bash

You can possibly try either rpm-ostree install zsh on the host or install zsh in toolbox, and then change the default shell with chsh.

But I got this :

bash: chsh: command not found

Hello @bijikeci,
To change to the zsh shell for the user go to /etc and look for passwd file. Edit this file as sudo using vim or vi if you haven’t installed vim-enhanced, like follows …
sudo vim /etc/passwd . It will open the file which will have only two entries or three after initial installation. Find your user settings in there (the file will look something like this)
<username>:x:1000:1000:<Real Name>:/var/home/<username>:/bin/bash
You press the insert key to start editing in Vim …
you want to change this bit at the end of the user settings :/bin/bash that tells the system what shell you use. So if you are using ZSH (which you already have layered with rpm-ostree install zsh) you would change that to :/bin/zsh. Then press the escape key to quit editing and enter :wq to write then exit vim. Since Bash won’t re-source the same file you will have to logout then back in. Hope that helps, it takes longer to write it out than do it. In Vim, if your not familiar with it, to get to the commands you press the : key.

But I have problem with logout before, I can’t re-login back to my account
Have you ever heard this issue ?

I have heard of people not being able to login, but not from changing the file /etc/passwd. This file is named passwd, but there is nothing about your login contained there other than you UID, Usename, Real Name, Home directory, and shell to use. The same for root above your user. (Don’t change roots settings). I change my shell this way all the time. Actually, I was running zsh, and would normally, but I was writing an article for Fed Mag on Bash, so I had to go back to bash. That is the file I change (and is the correct one to change) for this purpose. You could just do a reboot too if that is better for you. BTW chsh is not part of the core SB install, nor is it part of Bash AFAIK. I think it is a zsh command. So another way to get the shell changed is to layer zsh as described above, open a terminal, run sudo zsh to open a zsh shell, then zsh’s chsh will work for you and the changes should stick since you started it as sudo. Then logout and log back in (or reboot) into your newly installed zsh, though this seems way more complex than the original way I suggest.

So I’ve had problems with chsh in the past as well and if you use toolbox and zsh isn’t installed there things break. I just put this into my ~/.bashrc file:

[ ! -z "$PS1" ] && exec /usr/bin/zsh

What’s nice is that you can easily comment that line out if you are having odd behaivor with say a new toolbox, then after you insatll zsh, just remove the comment.

I do the PS1 check to ensure it’s an interactive shell, otherwise when you scp to the machine it also has problems.

For the future, use lchsh: sudo lchsh $USER will ask you what shell to use like chsh.

Afaik, chsh isn’t included because there isn’t really major reason it needs to be setuid when you can just use sudo instead.

1 Like

the easiest way that i do this is just with
sudo usermod --shell /path/to/shell < user >


And this is actually the administrators correct way to do it! Using the tools that were given. Thanks for reminding me @ellietheoracle.