How to Run the Bash Command Line in Windows 10

Windows + Linux = ❤

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.

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

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-Window

Reboot after you activate WSL.

of 05

Install a Distribution

linux in windows store

Launch the Windows Store and select a distribution to install.

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.

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.

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.