How To Run the Bash Command Line in Windows 10

Windows + Linux = ❤

Hands on keyboard with code on the screen

Seksan Mongkhonkhamsao/Getty Images


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 native Linux apps in X sessions on Windows 10.

Since its launch, WSL has matured. As of early 2019, 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 native command-line utilities.

of 05

Activate the WSL

Windows Subsystem for Linux

Ian Paul

By default, you cannot use WSL. Instead, you must turn on 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.

of 05

Install a Distribution

Picking a Linux distribution

 Ian Paul

Launch the Windows Store and select a distribution to install.

of 05

Run the Distribution for the First Time

Running the software

 Ian Paul

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.

of 05

Upgrading Your Installation

Getting a distribution up to date

 Ian Paul

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.

of 05

Using A Command Line Program

Running the Command Line

 Ian Paul

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 natively 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 native kernel image.