How to Run the Bash Command Line in Windows 10

Windows + Linux = ❤

What to Know

  • Activate WSL as an optional Windows feature or through a PowerShell command > reboot.
  • Next, go to the Windows Store > select and install a distribution.
  • Run the distribution and update if needed. Use it to run bash scripts or Linux command line utilities.

This article explains how to activate, download, install and use the Windows Subsystem for Linux (WSL) in Windows 10.

How to Run WSL in Windows

In the Windows 10 Anniversary Update, Microsoft added the Windows Subsystem for Linux to Windows 10 and even offered (in partnership with Canonical) a fully functional version of Ubuntu Linux—officially, just shell access, although it took about three nanoseconds for people to figure out how to run regular Linux apps in X sessions on Windows 10.

The Microsoft Store offers officially supported Linux distributions for Ubuntu, openSUSE Leap, SUSE Linux Enterprise, Debian/GNU Linux, and Kali Linux. Each of these distributions offers command-line access to Linux, from which you can run bash scripts or Linux command-line utilities.

01
of 05

Activate the WSL

wsl activation in ps

By default, you cannot use WSL. Instead, you must activate WSL as an optional Windows feature. Either open the Windows Features wizard and check the box or open a PowerShell prompt as administrator and execute:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Reboot after you activate WSL.

02
of 05

Install a Distribution

linux in windows store

Launch the Windows Store and select a distribution to install.

03
of 05

Run the Distribution for the First Time

Running the software

After the distribution is loaded onto your computer through Windows Store, run it. You'll have to create a new user account just as if you had installed the distribution as a stand-alone operating system on a fresh hard drive.

04
of 05

Upgrading Your Installation

Getting a distribution up to date

Your Linux distribution isn't a pretend environment—it's an actual Linux system that uses WSL instead of a standard kernel image. So you'll need to attend to normal Linux housekeeping.

Start with updating the distribution according to the system's architecture. For example, Debian and Ubuntu use apt.

05
of 05

Using A Command Line Program

Running the Command Line

After you've properly updated the distribution, you're free to run whatever programs you wish—including shell scripts and command-line utilities.

For example, you can execute the top command to check out system performance.

Technically, you cannot run Linux programs that require an X server, although the internet is littered with fairly straightforward workarounds to get Windows 10 to display an X window.

What's Under the Hood?

When you install a Linux distribution on Windows 10 you aren't getting a virtual machine or a program that does its best to pretend to be "Bash in Linux." It's actually a Linux distribution running normally on your PC thanks to the Windows Subsystem for Linux. The WSL is the "secret sauce" that allows Linux software to run on Windows. In essence, WSL replaces the Linux kernel; Linux works fully as intended, it's just using WSL rather than a regular Linux kernel image.

Was this page helpful?