How to change the default shell?

I installed fish with homebrew and I want to use that as my default shell instead of bash.

From docs about Fedora or Silverblue I tried chsh (doesn’t exist) and changing the shell in /etc/passwd (didn’t have any effect).

So how should I proceed to change my default shell?

You can set a custom shell in the Ptyxis terminal.
Screenshot from 2024-09-06 06-44-20

Thank you, but that would work only for Ptyxis. How can I change it so it also applies to ssh sessions?

ssh -t user@host 'fish'  # Replace user and host with your actual credentials

Would that work?

Thank you!

Yes it works, but still I wish there was a way to configure it as the default shell and not have to think about passing it each time…

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

from this link:
https://discussion.fedoraproject.org/t/how-to-change-the-default-shell-in-fedora-silverblue/21203/9

So that actually changes the /etc/passwd file, which should work but doesn’t, I don’t know why changing the password file doesn’t have any effect :thinking:

I just tried setting fish on my system and it worked.
Do you have something overriding it?

No I don’t think I have anything overriding it… Here is what my /etc/passwd:

tvbox@bazzite:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
tvbox:x:1000:1000:tvbox:/var/home/tvbox:/home/linuxbrew/.linuxbrew/bin/fish
erwan:x:1001:1002:erwan:/var/home/erwan:/bin/bash

if you run:

whereis fish

It should show /usr/bin/fish

You’re right, I got the path to linuxbrew from “which” instead of “whereis”. I fixed that.

So I was only testing in ssh, and I can confirm that this change applied to Ptyxis, without having to change Ptyxis config! Which is a good thing.

However ssh from a different computer still opens bash by default.

Also fish is on the image already, you shouldn’t need to use brew at all in this case, would probably help removing the path complexity from debugging, heh.

1 Like

OK, it’s working now, without any additional change! Apparently it took some time to apply to ssh as well?

I’m marking the usermod solution as correct. Thank you very much!

I know this answer, but it’s not valid for ublue distros because they don’t have the chsh command. Generally in Linux, to change the default shell for the logged in user:

❯ chsh -s /usr/bin/zsh

And if you want to know what shells you have to choose from:

❯ cat /etc/shells 
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/usr/bin/tmux
/bin/tmux
/usr/bin/zsh
/bin/zsh
/usr/bin/fish
/bin/fish

I looked at a workaround of using a distrobox, but the Debian install had different shells listed so I don’t think that’s a valid method. Outside of editing /etc/passwd manually and changing your default shell line there, I’m not sure of another way to do it.

I think Plyply’s answer is valid, it will edit /etc/passwd but from a command instead of doing it manually.

1 Like

Yep, I didn’t see it when I posted (wrote it last night, forgot to post until today!). Using usermod is exactly what we want, so to use a variable to make it work for anyone running it:

 sudo usermod --shell /usr/bin/zsh ${USER}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.