I don't use Windows and I don't have a copy available. I'm wanting to know what is the default shell for WSL2? Does it ship with sh, Bash, or ZSH? Or, does it use PowerShell -- which I know runs on WSL2 too.
Is this documented anywhere?
The default distribution on WSL is Ubuntu, and for Ubuntu:
bash
dash
So by transitive property, assuming that you meant "default interactive", I guess we can say that the default shell for WSL is bash
.
I thought about answering this a few days ago, but it didn't really seem to warrant the "bump". However, since Community bot picked this question today to auto-bump (since there's no accepted answer), I'll give it a slightly different spin.
First, as I think you are aware now, WSL supports many different Linux distributions. You can install a number of them from the Microsoft Store in Windows, or you can import a rootfs for most other distributions.
And I really prefer (and agree with) Debian's definitions of "default" when it comes to shells. There is always:
root
)./bin/sh
is linked to for running system and other "POSIX" scripts in as fast and compatible a manner as possible.When WSL was first announced, it was (perhaps poorly) called "Bash on Ubuntu on Windows". At that point, I think it would have been fairly obvious to answer your question with "Bash".
It was common to start your WSL/Ubuntu session using a bash.exe
command to launch WSL. This would always launch to the bash
shell inside an Ubuntu instance, even if the user's shell had been redefined in /etc/passwd
.
The ubuntu.exe
command (or one of its variants), on the other hand, would launch the WSL Ubuntu distribution into the user's /etc/passwd
shell.
Then we came to a gray area, where I don't believe it would be possible to say that there was any "default distribution" for WSL. You first installed/enabled WSL, then you picked a distribution from the Microsoft Store.
The bash.exe
method of starting was "semi-deprecated" (it was called a "historical command" in the Microsoft doc), and the new wsl.exe
replaced it. It always defaulted to the user's /etc/passwd
-defined shell, but any executable could be started as the parent process via wsl --execute <appname>
(or wsl -e
).
During this time, it would have been difficult to answer your question with anything other than "it depends on the distro", since there wasn't a "default" distro.
As of Windows 10 release 21H2 and Windows 11, there is a new WSL installation process. The base wsl
command is shipped with Windows, but it needs to be enabled via wsl --install
. This command, once again, does default to Ubuntu as the default distribution.
So as of now, it's (once again) fair to say that Ubuntu is the default distribution for WSL.
Who knows? It obviously has changed quite a bit over the 5 year history of WSL so far, so I'm sure it could change again :-).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments