How to Install Linux on Windows 10/11 using WSL 2

How to Install Linux on Windows 10/11 using WSL 2. In this post, we introduce Windows Subsystem for Linux, its advantages then show you how to use WSL 2 to install Linux on Windows 10/11.

What is Windows Subsystem for Linux (WSL)?

Windows Subsystem for Linux (WSL) is a Windows feature that enables users to run Linux based applications on Windows. Additionally, it also provides a Linux like environment so that developers build and test their software in an environment similar to production.

We could consider WSL to be the compatibility layer running between your Windows OS and Linux kernel. The WSL offers the Linux kernel and allows multiple distributions to be installed within a Microsoft environment, eliminating the need to start up a VM or rely on a remote Linux machine for development.

Above all, WSL requires fewer resources (CPU, Memory, and Storage) than an entire VM, and also allows Windows applications or tools along with Linux command line tools.

Along with running Linux command line tools and applications along with Microsoft’s command line, desktop, and stored applications, WSL also allows Windows files to be accessed from Linux, and to run Linux command line tools and applications. Because WSL is integrated with the Windows operating system natively, developers create and debug Linux applications using Windows tools such as Visual Studio Code and Visual Studio.

Running your Linux applications via WSL also saves a ton of system resources, since you are not be running a full blown virtual machine in your Windows Server. Developers who are using Windows machines to create their Linux applications find that WSL has a substantial benefit over virtual machines.

Do consider using WSL 1 if your projects must store in a Windows filesystem, or if a project requires cross compilation using both Microsoft and Linux tools.

Further, WSL offers several command line tools, utilities, and applications that help run a GNU/Linux environment directly on Windows, without the need for an additional virtual machine or dual boot setup.

Advantages of Windows Subsystem for Linux (WSL)?

Consequently, Windows Subsystem for Linux (WSL) is a subsystem that allows Windows to run Linux distributions. Helps developers to test their apps in a Linux environment and is to be used as a secure sandbox for running Linux commands as well as managing the servers remotely. Some of the additional benefits of WSL are:

1. Easy for Beginners

For those who are unfamiliar with Linux, WSL can be the best starting point. Without completely installing a new operating system, they can become familiar with Linux commands. Also, setting up WSL is a quick and simple process.

2. Hardware support is not a concern.

The hardware support for desktop Linux, particularly on laptops, is a persistent issue. However, WSL solves this issue.  Majority of PCs on the market still come preloaded with Windows. Instantly though you can get access a Linux desktop by downloading and installing WSL.

Future versions of “Linux on the desktop” might just require the download and installation of WSL and a Linux distribution from the Microsoft Store, as opposed to a separate operating system.

3. Excellent for Experts who use Open Source Tools

Microsoft claims that the main motivation behind creating WSL was to enable developers working with open source technologies to continue using Windows.

Open source software is frequently created with Linux in mind. Because of the same Unix like environment on Mac computers, developers have begun switching over to them. By utilizing WSL, Microsoft aims to win back these developers.

4. Better than VM or Dual Boot Setup

You don’t need to reboot or start a virtual machine because WSL already runs in Windows. With dual boot setup, create some hard drive space and do not miss to create a backup media in case something goes wrong. Further, for executing Linux software via Windows or vice versa, restart your system.

Although a virtual machine (VM) is simpler and quicker to set up, Windows and Linux find it challenging to share data since the VM is still fundamentally a different machine.

We have now reached the main part of the article How to Install Linux on Windows 10/11 using WSL 2.

How to Install Linux on Windows 10/11 using WSL 2

In this section, we show you how to install Linux on Windows 10 or 11 using WSL 2.

Prerequisites

  • A system running Windows 10 or 11 with a virtualization feature is enabled.
  • An administrator password is set up on your system.

Install Linux using WSL 2

By default, Windows 10 and 11 provides a WSL utility that allows user to easily install any Linux distro via command prompt or powershell. Follow the below steps to install Linux using WSL 2 on Windows.

Step 1 – Search for Windows command prompt or PowerShell, right client on the search result. Then click on the Run as administrator option to launch the command prompt.

Step 2 – Now, run the following command to install WSL 2 on Windows.

				
					wsl --install
				
			

This command downloads the latest Linux kernel, enables the required optional components, sets WSL 2 as your default, and installs the default Linux distribution on your system.

Step 3 – Next, you need to restart your system to complete the installation. If you want to see help information, run the following command.

				
					wsl --help
				
			

You should see the following screen.

Once you are finished, please proceed to the next step.

Install Specific Linux Distro Using WSL 2

With WSL, you install any supported Linux distributions on your system. Get a list of all available Linux distributions with the following command.

				
					wsl --list --online
				
			

This shows you the list of all distros on the following screen.

Now, you pick any Linux version from the above list and install it on your server. For example, to install Ubuntu 20.04 from the above list, run the following command.

				
					wsl --install -d ubuntu-20.04
				
			

You should see the following screen.

After the successful installation, check the status of installed Linux distributions using the following command.

				
					wsl --status
				
			

You get detailed information of installed Linux version on the following screen.

Install WSL 2 from Microsoft Store

In this step, you also install WSL from the Microsoft Store. Follow the below steps to install WSL 2 from Microsoft Store.

Step 1 – First, click on the Start => Search for Turn Windows Features on or off then click on it. This launches Windows Features screen.

Step 3 – Now, restart your system to apply the changes. After the successful restart, open the Store App from the start menu.

Step 4 – Search for Ubuntu 20.04 distro. You should see the following screen.

Step 5 – Click on the Install button to start the installation. After the successful installation, you can see your Ubuntu 20.04 in the start menu shortcut.

How to Install Linux on Windows 10/11 using WSL 2 Conclusion

Congratulations! You have successfully installed Linux on Windows 10/11 using WSL2. If you are running a previous version of Windows 10, you still install WSL 2, but the process is not quite as straightforward as it was with the 2004 upgrade. Lastly, WSL 2 changes the way ELF64 Linux binaries communicate with Windows and your computer’s hardware, but it still provides the same user experience as in WSL 1 (the currently widely available version).

Finally, the Windows Subsystem for Linux adds a compatibility layer that allows you to run the Linux binaries on Windows 10’s native operating system – thereby eliminating the need for installing VMs in order to perform most command line tasks.

Do explore more of Windows content, by navigating to our blog over here.  

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x