sodcalculator

10 Tech How-To

How to Set Up Linux Bash Shell on Windows 10

Guide 10-33920 · Updated · Step by step

This guide walks you through installing and using the Windows Subsystem for Linux (WSL) on Windows 10, which gives you a native Linux Bash shell without a virtual machine or dual boot. You’ll be able to run Linux commands, scripts, and tools directly from your Windows desktop. Before starting, ensure your Windows 10 is version 2004 or later (build 19041 or higher) for the easiest installation method.

What You’ll Need

  • Windows 10 version 2004 or higher (or Windows 11). Check by pressing Win + R, typing winver, and pressing Enter.
  • Administrator access to your PC to enable Windows features.
  • An internet connection to download the Linux distribution.
  • A Microsoft account is not required, but you’ll need to create a Linux user account during setup.

Step-by-Step

  1. Enable the Windows Subsystem for Linux feature. Open PowerShell as Administrator (right-click Start, select “Windows PowerShell (Admin)”). Run: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart. This turns on the WSL feature.
  2. Enable the Virtual Machine Platform feature. In the same PowerShell window, run: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart. This is required for WSL 2, which offers better performance and full system call compatibility.
  3. Restart your computer. Both features require a reboot to take effect. Save your work and restart.
  4. Set WSL 2 as the default version. After rebooting, open PowerShell (Admin) again and run: wsl --set-default-version 2. If you see a message about needing a kernel update, follow the link to download and install the WSL 2 Linux kernel update package from Microsoft, then run the command again.
  5. Install a Linux distribution. Open the Microsoft Store, search for “Linux” or a specific distribution like “Ubuntu” (the most popular). Click “Get” or “Install” on your chosen distro. Wait for the download and installation to finish. You can also install via command line: wsl --install -d Ubuntu (on newer builds).
  6. Launch the distribution. Once installed, click “Launch” in the Store, or find the app in your Start Menu (e.g., “Ubuntu”). The first launch will take a few minutes to set up.
  7. Create your Linux user account. You’ll be prompted to create a UNIX username (lowercase, no spaces) and a password. This is separate from your Windows login. You’ll use this to run sudo commands. Type your password when prompted (it won’t show as you type – that’s normal).
  8. Update your Linux packages. After setup, run sudo apt update && sudo apt upgrade (for Ubuntu/Debian) to update the package list and install security updates. Enter your password when prompted.
  9. Start using Bash. You now have a full Bash shell. Test it with lsb_release -a to see your distro version, or echo $SHELL to confirm it’s running Bash.

Common Mistakes

  • Skipping the Virtual Machine Platform. If you only enable WSL, you’ll get WSL 1, which is slower and lacks full compatibility. Always enable both features.
  • Not restarting after enabling features. The features won’t work until you reboot. If WSL commands fail, restart first.
  • Using the wrong PowerShell. You must run PowerShell as Administrator, otherwise the dism commands will fail with “Access denied”.
  • Choosing a distribution without knowing its package manager. Ubuntu uses apt, Fedora uses dnf, and openSUSE uses zypper. Update commands differ.
  • Forgetting the Linux password. You can reset it later, but it’s a hassle. Write it down or use a password manager.

Tips

  • Access your Windows files from Bash at /mnt/c/ (e.g., cd /mnt/c/Users/YourName). This lets you edit files with Linux tools and access them from Windows.
  • Run multiple distributions side-by-side; they are isolated.
  • Use wsl --set-version <distro> 2 to convert an existing WSL 1 distro to WSL 2.
  • Install Windows Terminal from the Store for a better tabbed experience with WSL.
  • You can run Linux commands from PowerShell or CMD by typing wsl <command>, e.g., wsl ls -la.
  • To shut down WSL completely, run wsl --shutdown from PowerShell.

Troubleshooting

  • “WSL is not installed” or “The Windows Subsystem for Linux optional component is not enabled.” Ensure you ran both dism commands and rebooted. Check with wsl --status in PowerShell.
  • “WSL 2 requires an update to its kernel component.” Download the MSI from the Microsoft WSL 2 kernel page, install it, then run wsl --set-default-version 2 again.
  • Installation from Store hangs or fails. Try installing via command line: wsl --install -d Ubuntu. If that fails, check your internet connection and Windows Store cache (run wsreset.exe).
  • “The service cannot be started” or error 0x8007007e. This often means virtualization is disabled. Go to BIOS/UEFI and enable “Virtualization Technology” (VT-x/AMD-V). Also ensure Windows Hyper-V is enabled (run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All in PowerShell as Admin, then reboot).
  • Bash opens but is slow or has “bad interpreter” errors. This may be a WSL 1 issue. Convert to WSL 2 with wsl --set-version <distro> 2.
  • Forgot your Linux password. Open PowerShell as Admin and run wsl -u root to enter as root, then use passwd <username> to reset it.

Frequently Asked Questions

Is WSL free?

Yes, WSL is a free Windows feature, and all Linux distributions in the Microsoft Store are free to download and use.

Can I run GUI applications (like Firefox) with WSL?

Yes, with WSL 2 and Windows 10 version 2004 or later, you can run Linux GUI apps using WSLg (included by default on Windows 11, and available on Windows 10 with recent updates). Install a GUI app like sudo apt install firefox and it will launch in a window.

How do I completely uninstall WSL?

Uninstall each Linux distribution from Settings > Apps, then disable the WSL and Virtual Machine Platform features via PowerShell (using the same dism commands but with /disable), and reboot.

Can I access my Windows C: drive from Bash?

Yes, it’s mounted at /mnt/c. For example, ls /mnt/c/Users shows your Windows user folders.

What is the difference between WSL 1 and WSL 2?

WSL 2 uses a real Linux kernel in a lightweight VM, offering full system call compatibility and better performance for file-heavy tasks. WSL 1 translates Linux system calls to Windows, which is faster for cross-OS file access but less compatible.

Do I need to enable Hyper-V to use WSL 2?

WSL 2 requires the Virtual Machine Platform, which is separate from Hyper-V. You don’t need to manually enable Hyper-V, but your computer must support virtualization and have it enabled in BIOS.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →