Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Install Bash on Windows: WSL, Git Bash, and More

Yes. You can install Bash on Windows, and for most people the best choice is Windows Subsystem for Linux (WSL), which runs a Linux environment with Bash alongside Windows. If you mainly need Bash for Git commands or simple scripts, Git for Windows is a lighter alternative.

Choose the Bash option that fits

There is no single Bash package built into every Windows installation. The right approach depends on what you plan to run:

  • WSL: Best for Linux command-line tools, development environments, and scripts that expect Linux behavior. It can run a full Linux distribution, such as Ubuntu, on Windows.
  • Git Bash: Best for Git and familiar Unix-style commands without setting up a Linux distribution. It is included with Git for Windows.
  • Cygwin or MSYS2: Options for users who need a broader collection of Unix-like tools or a particular development toolchain. They are separate environments with their own setup and compatibility considerations.

These choices are not identical. Bash is a shell; it does not, by itself, provide every Linux command or make Windows behave exactly like Linux. WSL supplies a Linux environment, while Git Bash and related tools provide selected Unix-like utilities adapted for Windows.

Install Bash through WSL

On a supported, up-to-date Windows 10 or Windows 11 system, the simplest WSL installation usually uses Windows Terminal, PowerShell, or Command Prompt opened as an administrator. Run:

wsl --install

The command enables the required Windows components and installs a default Linux distribution, typically Ubuntu on a standard installation. Restart if Windows asks you to. On the first launch, the distribution will finish setting up and ask you to create a Linux username and password. This account is separate from your Windows account; when typing its password in the terminal, characters may not appear on screen.

To choose a distribution, first see what is available:

wsl --list --online

Then install one by name, for example:

wsl --install -d Ubuntu

Exact availability and behavior can vary with Windows version and system configuration. If wsl --install is not recognized or does not complete, install current Windows updates and consult Microsoft’s WSL installation instructions for the manual setup steps relevant to your version. WSL may require virtualization support; on managed work devices, an administrator may need to enable or permit the necessary features.

Start Bash and use it with Windows

After installation, open the Linux distribution from the Start menu, or start the default WSL environment from a Windows terminal with:

wsl

Inside WSL, the prompt and commands are those of the installed Linux distribution. You can use commands such as pwd, ls, and grep, install Linux packages with that distribution’s package manager, and run Bash scripts. For example, Ubuntu users commonly install packages with sudo apt update followed by sudo apt install package-name.

Windows files are accessible from WSL under /mnt. For example, a Windows user’s Documents folder is commonly available at a path like /mnt/c/Users/Alex/Documents, with the drive letter represented in lowercase. Conversely, Windows applications can access the Linux filesystem through the network-style path exposed by WSL, often written as \\wsl$\Ubuntu\home\username in Windows tools.

For development work, Microsoft generally recommends keeping projects in the filesystem used by the tools doing most of the work. If you build and run code in Linux, store it in the WSL Linux filesystem, such as ~/projects, rather than under /mnt/c. This can improve performance and avoid some file-system behavior differences. Windows editors can still work with WSL files using supported WSL integrations.

Install Git Bash instead

If your goal is to use Bash-like commands with Git, install Git for Windows from its official website. The installer includes Git Bash; select it from the Start menu after installation. During setup, options control how Git integrates with Windows and which terminal or editor it uses. Most users can accept the recommended defaults unless they have a specific workflow requirement.

Git Bash is convenient for commands such as git status, ssh, and basic shell scripting. It does not install a complete Linux distribution, and a script that depends on Linux-specific services, package managers, kernel features, or exact GNU utilities may fail or behave differently. If a project says it requires Ubuntu or another Linux environment, use WSL rather than assuming Git Bash is equivalent.

What to know before choosing

WSL and Git Bash can both be useful on the same computer. Choose based on compatibility, not just on which prompt looks familiar:

  • Choose WSL when instructions use Linux package managers, Linux paths, or tools such as Linux compilers and services.
  • Choose Git Bash for Git workflows and common shell commands when you do not need a Linux distribution.
  • Choose Cygwin or MSYS2 when a project specifically documents or depends on that environment, or when you need its particular tool collection.

WSL 2, the default for many current installations, runs a Linux kernel in a lightweight virtualized environment. WSL 1 uses a different compatibility approach and may still be available in some configurations. You can check installed distributions and their WSL versions with wsl --list --verbose; conversion and version-management commands are documented by Microsoft. WSL 2 is not the same thing as installing Linux in a traditional dual-boot setup, and it does not replace Windows.

Common installation problems

If installation fails, check the cause before repeatedly running commands:

  • Command not found: Update Windows and verify that your version supports the WSL installation command. Older or restricted systems may require the documented manual process.
  • Virtualization or feature errors: Check that hardware virtualization is enabled in the computer’s firmware and that required Windows features are available. Work or school policies can prevent changes.
  • No distribution appears: Run wsl --list --online and install an available distribution explicitly with wsl --install -d followed by its listed name.
  • Linux commands do not work in PowerShell: Open the distribution or run wsl first. PowerShell and Bash are different shells with different command syntax.
  • Files or scripts behave differently: Check whether the script expects Linux tools, permissions, or line endings. Keep Linux-oriented projects in the WSL filesystem and use tools suited to the environment.

Frequently Asked Questions

Is Bash already installed on Windows?
Not as a general Linux Bash environment. Windows includes PowerShell and Command Prompt; install WSL for Linux Bash or Git for Windows for Git Bash.

Is WSL free?
WSL is a Windows feature, and common Linux distributions such as Ubuntu are available at no charge. Internet access may be needed to download components and distributions; network or organizational restrictions can affect installation.

Can I run Bash scripts on Windows?
Yes. Run Linux-oriented scripts in WSL and Windows-oriented scripts in an environment they support. A script may need changes if it assumes particular Linux utilities, paths, permissions, or system services.

Can I use Bash and PowerShell on the same computer?
Yes. They can coexist. Open the shell you need, or use Windows Terminal to keep separate tabs or profiles for PowerShell and a WSL distribution.

Do I need to replace Windows with Linux?
No. WSL runs a Linux environment within Windows, and Git Bash provides shell tools without replacing the operating system. Neither requires a dual-boot setup.

Install Bash on Windows: WSL, Git Bash, and More
Scroll to top