WSL: Can't change default shell
- A brief description
Would like to use zsh instead of bash, mainly because of the oh-my-zsh scripts and all the lovely things they do.
- Expected results
Opening bash.exe after changing default shell to zsh opens zsh instead of bash.
- Actual results (with terminal output if applicable)
zsh was running just fine, until I closed and opened bash.exe again, when it was running bash once more.
- Your Windows build number
Sorry, don’t know. Just installed the update this evening though.
- Steps / commands required to reproduce the error
sudo apt-get install git zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
- Quit bash and open again.
- Also tried running
chsh -s /usr/bin/zsh but that didn’t seem to make much difference.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 30
- Comments: 24 (4 by maintainers)
The most recent Windows Insider build has added wsl.exe which performs two functions:
Otherwise, it behaves exactly like bash.exe
As a workaround I’d suggest the following:
chsh -s /usr/bin/zsh
Create a Windows shortcut to \Windows\System32\bash.exe -c “/usr/bin/zsh”
I think this will help you How to Use Zsh (or Another Shell) in Windows 10
@hrlngrv I only use bash for one thing, to install zsh =)
The bash.exe Windows command which launches the Linux subsystem apparently just launches /bin/bash. It’s not a true login, so it doesn’t access /etc/passwd, even using bash.exe’s --login command line switch. OTOH, it’s possible to use -c zsh to run zsh or -c login to log into the Linux subsystem, and that does access /etc/passwd and the default shell setting.
A normal
-c zshsymlink opened up in the wrong directory to me, but I managed using this (note the tilde):@benhillis I’m curious what information init pulls from /etc/passwd. bash.exe always starts as user root, uses the working directory from which it was run (console) or given in the .lnk shortcut (GUI), and doesn’t run the chosen default shell. Is the info that user root has user number 0 and group number 0? There’s nothing much else in /etc/passwd.
As for funniness, you could always rename bash.exe to WSL.EXE, or leave bash.exe always to run /bin/bash and add WSL.EXE to run the selected default shell.
bash may be the most popular of shells, but long-time zsh and csh (and maybe also ksh) users want to use their favorites.
Is
wsl.exeavailable in the stable builds yet?I noticed is still not a complete work-around, e.g. the environment contains
SHELL=/bin/bashand thus executingtmuxit usesbashas a default shell.A quick way to get build number is to open a command prompt. It is at the top.
Microsoft Windows [Version 10.0.14393]