How to Use Linux Terminal in Windows 10

Linux Computer

You can now access most of the Linux command-line utilities and applications on top of Windows 10 OS using Windows Subsystem for Linux (WSL).

Although Windows is the most popular operating system for desktops and laptops, it is not as secure and open-sourced as Linux. That’s is why Linux is loved by developers and professionals.

Microsoft has started a partnership with Canonical, creators of Ubuntu Linux. This paved way for Linux users to use Linux on Windows. Yes, you can run Linux on top of Windows 10 without the need for a dual boot, or using VMWare/VirtualBox, or installing it as your main Operating System.

You can open a Linux terminal in Windows 10 and install and access Linux commands and software from the terminal. In this article, we’ll walk you through the steps to install and run the Linux terminal on Windows 10 OS.

Enable Windows Subsystem for Linux (WSL) and Install Ubuntu in Windows 10

If you want to run Linux on Windows 10, you must first enable the ‘Windows Subsystem for Linux’ feature before you can download and install the distribution of Linux that you want to use.

The Windows Subsystem for Linux (WSL) is a feature that creates a GNU/Linux Environment which enables you to run most of the command-line utilities, tools, and applications on top of Windows OS.

By enabling Windows 10’s Linux subsystem, you can install and run supported versions of Linux distros such as Ubuntu, OpenSuse, Debian, etc.

First, Check your Windows Version

But before we get into how to enable WSL and install Linux, you need to make sure that you’re running a compatible version of Windows 10. WSL is only supported on both Windows 10 64-bit (from version 1607) and Windows Server 2019.

 To check your Windows version and build, go to ‘Settings’ from Windows Start menu.

Next, click ‘System’ setting.

Then, scroll down and click ‘About’ at the bottom of the left pane to view About section.

On the About page, under Windows specifications, you can see the ‘Version’ and ‘OS build’ of your Windows 10.

Enable Windows Subsystem for Linux

There are two different types of WSL versions: WSL 1 and WSL 2. While they both provide seamless integration of Linux within Windows, WSL 2 is the latest and fastest version with supports full Linux kernel and system call compatibility. WSL 1 uses a translation or compatibility layer between Linux and Windows.

  • WSL 2 – For Windows 10 x64 systems: Version 1903 or higher, with Build 18362 or higher.
  • WSL 1 – For Windows 10 x64 systems: Version 1709 or higher, with Build 16215 or higher.

Regardless of which version of WSL you want to use you first need to enable it. To do this, start type typing ‘Turn Windows features on and off’ into the Start Menu search field.

Select ‘Turn Windows features on and off’ control panel from the result.

Then, scroll down to ‘Windows Subsystem for Linux’, check the box in front of it, and click the ‘OK’ button.

Once the changes are applied, click ‘Restart now’ to restart your computer

If you wish to only install WSL 1, you can now restart your computer and move on to install your Linux distro.

Enable WSL 1 via PowerShell

You can also enable WSL via the ‘PowerShell’ command-line tool. This does the same job as the Windows Features control panel. For that, open ‘PowerShell’ as an Administrator and run the command below.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enable WSL 2

We recommend you upgrade your WSL to version 2 for faster performance speed, and to run a real Linux kernel directly on Windows 10. All you need to do is enable the ‘Virtual Machine Platform’ feature in addition to Windows Subsystem for Linux feature on ‘Turn Windows features on and off’.

Wait for the changes to be applied, then restart your computer.

Enable WSL 2 via PowerShell

This first step to enable WSL 2 is enabling the Virtual Machine Platform feature component on Windows. You can also enable WSL 2 via the ‘PowerShell’ command-line tool. To do that, open ‘PowerShell’ as an Administrator and run an additional command with the WSL 1 command.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Set WSL 2 as the Default Version

Before setting up WSL 2 as your default version for all Linux distributions, download the WSL Linux kernel package update for x64 systems.

Run the .msi installer downloaded and install it. It will take only seconds.

To set WSL 2 as your default version when installing a new Linux distribution, open PowerShell and run this command the following command:

wsl –set-default-version 2

Then restart your computer to switch the feature from WSL 1 to WSL 2.

Install your Linux distribution of choice

Now, we’re going to actually install a Linux distribution. First, search for ‘Microsoft Store’ in the Start Menu search field. Then, open it from the search result.

You’ll see a list of every Linux distributions currently available in the Windows Store which are supported by WSL.  

  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • openSUSE Leap 15.1
  • SUSE Linux Enterprise Server 12 SP5
  • SUSE Linux Enterprise Server 15 SP1
  • Kali Linux
  • Debian GNU/Linux
  • Fedora Remix for WSL
  • Pengwin
  • Pengwin Enterprise
  • Alpine WSL

All of theses distributions are available for free. For our tutorial, we’ll select ‘Ubuntu’.

From the Ubuntu distribution’s page, Click the ‘Get’ button.

Ubuntu will be downloaded and installed automatically. 

Once the installation finished, click the ‘Launch’ button to launch the terminal. You can also launch the app from the Start Menu.

A new Ubuntu terminal window will appear. The first launch will take a few minutes for registering the Ubuntu environment with WSL. Once that’s finished, you will be prompted to create a ‘new Unix username’ and ‘password’. Enter and complete setup.

These don’t need to be the same as your Windows username or password.

Once, the set up finished, you’ll find yourself at the bash command line. It’s better to update the software right away. In Ubuntu, you can search for, download, and install software updates, all from the apt command.

Enter the below command to update the software. And you’ll be prompted for the password, enter your password to run the command as an administrator.

sudo apt update

The ‘update’ command is used to update the Ubuntu repositories.

Ubuntu will download a series of package lists.

But they are not upgraded yet. To upgrade all available packages, enter the following command:

sudo apt upgrade

Enter ‘Y’ at the prompt to continue with installation.

The ‘dist-upgrade’ command upgrade packages to their latest versions.

Upgrade WSL1 to WSL 2 for Ubuntu

If you wish to upgrade the existing WSL 1 version to WSL 2 for a specific distribution. Then, run the following command in PowerShell.

wsl –set-default-version <Distro> 2

Replace ‘<Distro>’ with the name of whichever distro (Ubuntu) your WSL 1 install runs.

Now, you can access Linux commands and software on a Windows 10 system using this Ubuntu Environment.

bash shell on Windows 10

You now have a full command-line ‘bash’ shell based on the Linux distribution you installed. You can access all the Linux commands and applications via bash shell.

To run bash shell, type ‘bash’ into the Start Menu search field and click to open the bash command-line tool.

Now, you can start running commands there.

Enjoy Linux on Windows!