What is the default shell in the Windows Subsystem for Linux (WSL)?

Evan Carroll

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?

NotTheDr01ds

Short answer

The default distribution on WSL is Ubuntu, and for Ubuntu:

  • The default interactive shell is bash
  • The default non-interactive shell is dash

So by transitive property, assuming that you meant "default interactive", I guess we can say that the default shell for WSL is bash.

More detail

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:

  • a default interactive shell, that is assigned by default to users when created (and to root).
  • a default non-interactive shell that is, by definition, whatever /bin/sh is linked to for running system and other "POSIX" scripts in as fast and compatible a manner as possible.

Some history

  • Early WSL Days

    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.

  • Recent history

    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.

  • Today

    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.

  • Tomorrow

    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.

edited at
0

Comments

0 comments
Login to comment

Related

Using Windows Subsystem for Linux (WSL) from Sublime Text

Intermittent, random 'file not found' errors under Windows Subsystem for Linux (WSL)

Visual Studio Code, Python linting with WSL (Windows Subsystem for Linux)

How to use MySQL in WSL (Windows Subsystem for Linux)?

ssh-agent reset in Windows Subsystem for linux (WSL)

VSCode as Git editor on Windows Subsystem for linux (WSL)

Can ddev work with WSL (Windows Subsystem for Linux)?

Find active serial ports in Windows Subsystem for Linux (WSL)

No internet connection on WSL Ubuntu (Windows Subsystem for Linux)

How to run RediSearch module with Redis on WSL (Windows Subsystem for Linux)

Laravel Sail on Windows Subsystem for Linux (wsl)

What is the difference between Windows Subsystem for Linux (WSL), Cooperative Linux (coLinux), and Cygwin?

User accounts under WSL (Windows Subsystem for Linux)

How do I change the language of the Linux subsystem in Windows 10 (WSL)?

Upgrade of Linux Subsystem for Windows 10 (WSL) to Ubuntu 16.04 not working

Windows Subsystem for Linux (wsl) - Get Default Version

ssh-agent reset in Windows Subsystem for linux (WSL)

Open URL with VIM in Ubuntu WSL (Windows Subsystem for Linux)

Windows Subsystem for Linux (WSL): what can't I do with the Ubuntu application for Microsoft Windows?

How to make a Tape Drive available in Windows Subsystem for Linux (WSL)?

A better terminal experience for Windows Subsystem for Linux(WSL)?

How can I reset the Windows Subsystem for Linux (WSL) back to defaults?

Windows Subsystem Linux (WSL) don't catch ctrl+backspace with power shell

Windows Subsystem for Linux (WSL) not actually saving $DOCKER_HOST

What are the limitations of the Windows Subsystem for Linux?

Installing mitmproxy on Windows Subsystem for Linux (WSL)

How to change default directory in Windows Subsystem for Linux

The status of the previously created Ubuntu folders in Windows Subsystem for Linux (WSL)

What is the system distribution in the Windows Subsystem for Linux (WSL)?