sodcalculator

10 Tech How-To

How to Install and Use Bash on Windows 11

Guide 10-55695 · Updated · Step by step

This guide walks you through installing and using Bash (the Linux command-line shell) on Windows 11 via the Windows Subsystem for Linux (WSL). By the end, you’ll be able to run Linux commands, install software, and script directly from your Windows PC. You’ll need Windows 11 (any edition) and administrative access to your computer.

What You’ll Need

  • Windows 11 (64-bit, version 21H2 or later)
  • Administrator rights on your PC
  • Internet connection (to download WSL and the Linux distribution)

Step-by-Step

  1. Open PowerShell as Administrator – Right-click the Start button and select “Windows Terminal (Admin)” or “PowerShell (Admin)”. If prompted by User Account Control, click “Yes”.
  2. Enable WSL – In the terminal, run this command and press Enter: wsl --install. This enables the required Windows features and installs the default Linux distribution (usually Ubuntu) automatically.
  3. Restart your PC – After the command completes, you’ll be asked to restart. Save your work and restart.
  4. Set up your Linux username and password – After restart, a terminal window will open automatically to finish the installation. Enter a username (lowercase letters, no spaces) and a password (you won’t see characters as you type). This is separate from your Windows login.
  5. Verify Bash works – Type bash --version and press Enter. You should see version information. If not, close and reopen the terminal.
  6. Access Bash anytime – Open the Start menu, type “Ubuntu” (or the distro you installed) and click it. Or open any terminal and type wsl.
  7. Install additional packages – Use the Linux package manager. For Ubuntu/Debian, run sudo apt update then sudo apt install <package-name> (e.g., sudo apt install git).

Common Mistakes

  • Not running as administrator – The wsl --install command fails with “Access denied” if you don’t have admin rights. Always right-click and choose “Run as administrator”.
  • Skipping the restart – WSL won’t work until the required Windows features are enabled, which only takes effect after a reboot.
  • Using the wrong package manager – If you installed a non-Ubuntu distro (e.g., Debian, Kali), commands like apt may not work. Use the distro’s package manager (e.g., dnf for Fedora, pacman for Arch).
  • Confusing Windows paths with Linux paths – In Bash, C:\Users\Name is not valid. Use /mnt/c/Users/Name to access Windows files.
  • Forgetting to update – New WSL installs often have outdated package lists. Run sudo apt update before installing anything.

Tips

  • Set WSL 2 as default – WSL 2 offers better performance and full system call compatibility. Check with wsl --set-default-version 2.
  • Access your Windows files – Your C: drive is mounted at /mnt/c/. For example, cd /mnt/c/Users/YourName/Documents.
  • Use the same terminal for Windows and Linux – Windows Terminal lets you open multiple tabs, each with either PowerShell or Bash.
  • Run a single Linux command from Windows – In PowerShell or CMD, type wsl <command> (e.g., wsl ls -la) to execute a Linux command without entering Bash.
  • Customize your prompt – Edit the .bashrc file in your home directory to change the prompt, add aliases, or set environment variables.

Troubleshooting

  • “WSL is not installed” error – Run wsl --install again as administrator. If it still fails, enable the “Windows Subsystem for Linux” and “Virtual Machine Platform” features manually via “Turn Windows features on or off”, then restart.
  • “The operation timed out” during install – This is often a network issue. Check your internet connection, disable VPN or proxy, and try again. You can also download a distribution manually from the Microsoft Store.
  • Bash opens but shows “command not found” for common tools – The package list is likely outdated. Run sudo apt update and then sudo apt upgrade.
  • WSL won’t start after a Windows update – Open PowerShell as admin and run wsl --update. If that fails, restart your PC and try again.
  • “Please enable the Virtual Machine Platform” error – Go to “Turn Windows features on or off”, check “Virtual Machine Platform”, restart, then run wsl --set-default-version 2.

Frequently Asked Questions

Is Bash the same as the Linux terminal?

Bash is a shell (command interpreter) that runs inside a terminal window. The terminal is the window itself; Bash is what processes your commands. On Windows, you get a terminal window that runs Bash via WSL.

Can I run graphical Linux apps with WSL?

Yes, WSL 2 supports GUI applications. Install a GUI app (e.g., sudo apt install gedit) and launch it from Bash. It will appear in a separate window, just like a native app.

How do I uninstall Bash/WSL?

Open PowerShell as admin and run wsl --unregister <DistroName> (e.g., wsl --unregister Ubuntu) to remove the distribution. To completely disable WSL, uncheck the Windows features or run wsl --install --no-distribution? Actually, use wsl --shutdown first, then uninstall via Settings > Apps.

Can I access my Windows files from Bash?

Yes, Windows drives are mounted under /mnt/. For example, ls /mnt/c/Users lists your Windows user folders. This works both ways – you can edit the same file from either Windows or Linux.

Do I need to enable Hyper-V?

No, WSL 2 uses a lightweight virtualization technology that doesn’t require the full Hyper-V feature. However, you must have “Virtual Machine Platform” enabled, which the wsl --install command does automatically.

What’s the difference between WSL 1 and WSL 2?

WSL 1 translates Linux system calls to Windows, while WSL 2 runs a real Linux kernel in a lightweight VM. WSL 2 offers better compatibility and performance for most tasks, but uses more memory. You can switch with wsl --set-version <Distro> 2.

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 →