Back in 2017, Windows released Windows Subsystem for Linux that lets developers run a GNU/Linux environment, including most command-line tools, utilities, and applications directly in Windows without setting up a virtual machine or dual-boot.

WSL2 has since been released, and it’s an improvement over version 1. The new and improved version comes with performance boost, full system call compatibility, and built with a new architecture and that delivers features that make WSL an amazing way to run a Linux environment in Windows.

To install WSL 2 on Windows 10, these two requirements must be met:

  • Windows 10 May 2020 (2004), Windows 10 May 2019 (1903), or Windows 10 November 2019 (1909) or later
  • A computer with Hyper-V Virtualization support

Since you can now install Linux systems, including Debian directly in Windows, let’s go ahead and install Debian. Before you can do that, you must first enable WSL or WSL2 in Windows.

Enable WSL in Windows

To enable WSL in Windows, you will want to open PowerShell terminal as administrator. Click on Start then begin typing PowerShell.

Next, right-click Windows PowerShell app and choose to run as administrator.

When the console opens, run the commands below:

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

After installing, you should get a success message similar to the lines below:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844

Image Version: 10.0.19042.844

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Enable Virtual Machine Platform

WSL 2 requires Windows 10 Virtual Machine Platform to be enabled. This is not Hyper-V. To enable the VM platform feature in Windows, run the commands below from the same PowerShell administrator’s console.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you’re using Windows 10 version lower than 2004, then use the commands below:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

When you’re done running the commands above, restart your computer for all the configuration changes to apply. If you don’t restart, the below command might not be recognized.

After restarting your computer, login back in and launch PowerShell as administrator. Then run the commands below to configure WSL 2 as the default version of WSL.

wsl --set-default-version 2

PS: If you get an error about not having Linux kernel installed, get it from the link below and run it in Windows, then try the command above again.

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Install Debian in Windows 10

Now that WSL 2 is installed and ready to be used, open the link below to download and install a copy of Debian from Windows store.

Debian on Windows allows you to use Debian Terminal and run Debian command line utilities including bash, ssh, git, apt and many more.

Click the Get button and install. After installing Debian, you’ll want the option to launch Debian from Windows WSL environment.

After downloading and installing, you will get a Launch button.

After launching Debian, it should install and prompt to create your account.

Installing, this may take a few minutes…
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: ngubri
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
ngubri@DESKTOP-M1235UB:~$

That should do it!

Some troubleshooting commands to run when you run into issues.

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Now simply launch Debian from Windows start by searching for it. You can also pin it to the taskbar and always have it launch from there.

That should do it!

To ensure that WSL 2 is enabled in your system, open the Windows command prompt and run the below-mentioned command:

 wsl -l -v
 //OR
 wsl --list --verbose

Note that the above command only works on Windows build version “18362” and higher. If the output indicates the WSL version properly, that means WSL 2 is enabled in your system:

If you are still running the WSL version 1, then use the following command to enable WSL 2:

 wsl --set-default-version 2

Though WSL 2 is the latest version, there are still some features that are only supported by WSL 1, such as quick access to files stored on Windows, serial port support, etc. So to set a specific version of WSL to a specific distribution, use the command:

wsl --set-version [distro_name] [wsl_version_number]

Replace the “[distro_name]” with the Linux distribution name and mentioned the WSL version in the place of “[wsl_version_number].” (example: wsl –set-version Debian 2)

Conclusion:

WSL is a Windows feature that allows Windows 10 users to run Linux on Windows 10 natively. There are two main versions of WSL; WSL 2 is the updated version of WSL 1 and supports all system calls, and 20% faster than its predecessor.WSL converts the Linux calls into windows calls and executes them, though WSL 2 has its own specifically designed kernel that no longer needed call system translation. After enabling WSL in Windows and installing Linux distribution, you can use bash shell for all compatible utilities. It is quite helpful for developers who are interested to learn Linux on Windows.

WSL 2 uses an actual Linux kernel that allows Linux containers. WSL 1 was genius with running Linux on the Windows kernel, but of course lacked some of the features, such as containers. 

Although the WSL 2 is the current and overhauled version, some exceptions might make you use WSL 1. Which version you should use is a personal choice, but I would recommend going with WSL 2 because it is efficient and allows you to install Linux updates easily.

Reference:

https://websiteforstudents.com/

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *