How To Install the Windows Subsystem for Linux 2 on Microsoft Windows 10. Wsl install Windows 11

Install WSL- Windows Subsystem for Linux on Windows 11

Microsoft has made lots of changes since the integration of WSL in Windows 10 which is now also available in Windows 11 as well. Earlier it was not possible to run Linux on Windows without using Virtual Machines platforms, however with WSL 1/2 now it is. However, to activate and use the Windows subsystem for Linux- WSL the user has to go through the “Turn Windows features on or off” or “Command line“.

install, windows, subsystem, linux

Install and enable WSL on Windows 11

Open Turn Windows features on or off

On Windows 11 or 10 go to the search box and type – features. Soon you will get “Turn Windows features on or off“, select it to open the same.

Install Windows Subsystem for Linux

Scroll down and search for the Windows subsystem for Linux and check the box given for it. After that, click on the OK button to install and enable WSL.

Reboot the system

Finally, reboot the system to properly integrate this feature.

Use Powershell command to enable WSL

If you don’t want to use the above GUI method, then simply right-click on the Start button of Windows 11 and select “Windows Terminal (Admin)“.

WSL 2: Getting started

Paste the given command and hit the Enter key.

Enable-WindowsOptionalFeature.Online.FeatureName Microsoft-Windows-Subsystem-Linux

Type Y, hit the Enter key to restart the system.

Install Distro

Right-click on the Start button and type the below command to install any available Linux distro, for example, if you want to get Ubuntu WSL then the command will be:

Alternatively, you can use the Microsoft store for WSL distros.

To check the available Distro:

To install Ubuntu:

wsl.exe.-install ubuntu-20.04

Once done, go again to the Search box and type Ubuntu to access the Linux bash.

How To Install the Windows Subsystem for Linux 2 on Microsoft Windows 10

The Windows Subsystem for Linux 2, WSL 2 or WSL for short, is a tool on Microsoft Windows 10 that allows developers to run a Linux environment directly on Windows without any modifications, secondary Virtual Machine software, or dual-boot setups. The WSL natively integrates with most applications on your workstation, allowing for a Linux-like development experience on Windows. The WSL accomplishes this by using Microsoft’s built in virtualization software called Hyper-V to run.

In this tutorial you’ll enable the WSL, install Ubuntu 20.04 onto your workstation using the WSL, and install Microsoft’s new Windows Command Line to access your Ubuntu 20.04 installation. This will provide you with a Linux programming environment that is native to Windows.

Prerequisites

In order to follow along with this guide, you’ll need:

  • Personal Computer with Windows 10 installed: The Windows Subsystem for Linux 2 requires Windows 10 version 1903 or higher with build 18362 or higher. For ARM64 systems, version 2004 or higher with build 19041 is required. Builds lower than this will not support the WSL 2.

If you are not installing the WSL on a virtual machine, you can skip this warning entirely.

Step 1 — Enabling Windows Services for the WSL

The first thing you need to do is enable specific Windows services so that you can run the WSL. These services come with Windows but are turned off by default until you decide you need them. Open up the Start menu and search for PowerShell. You’ll need to right click on PowerShell and click on Run as Administrator.

Once you’ve done this, a PowerShell window will open. You’ll use the Windows Deployment Image Servicing and Management tool to enable optional Windows features that are disabled by default. Run the following command to enable the WSL feature:

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

Once you run the command you’ll see output similar to this:

outputDeployment Image Servicing and Management tool Version: 10.0.19041.844 Image Version: 10.0.19042.985 Enabling feature(s) [100.0%] The operation completed successfully.

Next, run the following command in PowerShell to enable Windows’ Virtual Machine Platform. This enables the second generation of the WSL by enabling Hyper-V and allowing Windows’ to install Linux using it.

PS C:\Windows\system32 dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Once you run the command you’ll see output similar to this:

outputDeployment Image Servicing and Management tool Version: 10.0.19041.844 Image Version: 10.0.19042.985 Enabling feature(s) [100.0%] The operation completed successfully.

Once you have done this you will need to restart Windows for these changes to take place.

After the restart is finished, log back in to your workstation.

Next you’ll need to download the latest Linux kernel update package from Microsoft and install it.

To install this package, click to download the wsl_update_x64.MSI package to your local workstation. Once it is downloaded, run the application and follow the prompts to install it.

Finally, you need to set the default version of the WSL to version 2. Open another PowerShell terminal as an administrator and run the following command:

PS C:\Windows\system32 wsl.-set-default-version 2

Once you run the command you’ll see output similar to this:

outputFor information on key differences with WSL 2 please visit https://aka.ms/wsl2

Now that you’ve done this the WSL 2 is enabled and ready to run on your workstation. Next you’ll need to install a Linux-based operating system using the WSL 2.

Step 2 — Installing Ubuntu 20.04 using the WSL

Now that you have the WSL 2 installed, you next need to install a Linux distribution from the Microsoft Store. For this tutorial we will be installing the default Ubuntu option from the store, which happens to be Ubuntu 20.04 at this time. There are many different options to choose from and all should take a nearly identical approach to installation as laid out in this tutorial.

Open your Start menu, search for the Microsoft Store, and open it.

Locate the search bar in the upper right-hand corner and search for Linux.

Many options will appear; select the Ubuntu tile to install the latest supported version of Ubuntu. Click the Get button to add the app to your account. Once you’ve done this, the Get button will be replaced by the Install button. Click that button to install Ubuntu to your local workstation. Once the installation is done a Launch button will appear. Click this to launch Ubuntu.

The first time you launch Ubuntu it will inform you that it is performing initial configuration that may take a few minutes. After this it will prompt you for a Linux system username and password. This username and password doesn’t have to be the same as your system but it will be required for you to be able to use sudo to gain admin privileges.

Once you have created your user the initial setup is complete and Ubuntu is ready to be used.

Now that you have Ubuntu installed, you’ll install a more robust terminal for accessing Ubuntu through Windows.

Step 3 — Installing and Configuring the New Windows Command Line

Ubuntu provides a default terminal for use, but Microsoft open sourced and reimplemented their Terminal tool and branded it at Windows Terminal. This terminal supports many more customization and ease-of-use options than the default Ubuntu terminal, so you’ll want to install it.

Next you’ll install this terminal on your workstation. Navigate back to the search bar in the Microsoft Store and search for Terminal.

Install the Windows Terminal the same way you installed Ubuntu, by clicking Get and Install. Launch the terminal by clicking Launch or selecting the program from your Start menu.

By default, the Windows Terminal opens up a PowerShell console.

If you want to open a different console, click the down arrow button to see what is available. You have access to PowerShell, Command Prompt, and Azure Cloud Shell by default. When you install any WSL Linux, it will appear here as well like the Ubuntu install did. Clicking Ubuntu will open an Ubuntu shell in a new tab.

If you want to change some of the Terminal’s default options, click the down arrow button and select Settings.

Next, set Ubuntu as your default console. Under Default Profile select your Ubuntu WSL image, and click Save to make it your default option.

Now when you click the button or open a new terminal Ubuntu will be the default shell.

You now have the new Windows Command Line tool installed and configured to open your WSL Ubuntu terminal by default. You are now ready to use Linux on Windows using the WSL.

Conclusion

You now have a fully functioning Linux environment running in Windows. You configured your computer to take advantage of the Windows Subystem for Linux, and installed an Ubuntu environment using the WSL. If you prefer a different Linux distribution, there are others you can install, including Debian, SUSE, or Kali Linux. From here, you can install developer tools to have a complete Linux development environment running on Windows.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Remote development in WSL

This tutorial walks you through enabling Windows Subsystem for Linux (WSL) and running Visual Studio Code in WSL using the WSL extension.

Prerequisites

Install the extension

The WSL extension enables you to run Visual Studio Code within the Windows Subsystem for Linux (WSL).

Prerequisite check

With the WSL extension installed, you will see a new Status bar item at the far left.

The Remote Status bar item can quickly show you in which context VS Code is running (local or remote) and clicking on the item will bring up the WSL extension commands.

Enable WSL

Windows Subsystem for Linux (WSL) is an optional feature on Windows 10. You can enable it through the Windows Features dialog or PowerShell.

Windows Features dialog

In the Windows search bar, type ‘features’ to bring up the Turn Windows Features on and off dialog. Scroll down and check Windows Subsystem for Linux.

Select OK and you will be prompted to restart Windows.

PowerShell

If you prefer, you can open PowerShell as an Administrator and type:

Enable-WindowsOptionalFeature.Online.FeatureName Microsoft-Windows-Subsystem-Linux

After the command runs, you will be prompted to restart Windows.

Check WSL

After restarting Windows, you can check that you have WSL enabled by opening a Command Prompt and typing ‘wsl’.

WSL is enabled, but you haven’t installed a Linux distribution yet.

Install a Linux distro

You install Linux distributions for WSL from the Microsoft Store. You can use the store app, or search for a Linux distro in the Windows search bar. Choose the Linux distribution you want to install (for example Ubuntu) and follow the prompts.

install, windows, subsystem, linux

Select Install.

And when done, select Launch to get started. This will open a Linux terminal and complete the installation. You’ll need to create a user ID and password since you are setting up a full Linux instance. You are now running Linux on Windows.

Python development

If you don’t have Python already installed, run the following commands to install Python3 and pip, the package manager for Python, into your Linux installation.

sudo apt update sudo apt install python3 python3-pip

Start with the canonical “Hello World” app. Create a new folder called “helloWorld” and then add a Python file that will print a message when run:

mkdir helloWorld cd helloWorld Echo ‘print(“hello from python on ubuntu on Windows!”)’ hello.py python3 hello.py

In a remote Linux environment (this WSL distro is technically another machine without UI, that just happens to be running locally on your computer), your development tools and experiences are pretty limited. You can run Vim in the terminal to edit your file, or you can edit the sources on the Windows side through the \\wsl mount:

The problem with this model is that the Python runtime, pip, or any conda packages for that matter, are not installed on Windows.

Remember, Python is installed in the Linux distro, which means if you’re editing Python files on the Windows side, you can’t run or debug them unless you install the same Python development stack on Windows. And that defeats the purpose of having an isolated Linux instance set up with all your Python tools and runtimes!

Run in WSL

In the WSL terminal, make sure you are in the helloWorld folder, and type in ‘code.’ to launch Visual Studio Code. The ‘.’ argument tells VS Code to open the current folder. If you use the Insiders version of VS Code, you will have to run ‘code-insiders.’ instead.

Note: If this command does not work, you may need to restart your terminal, or you may not have added VS Code to your path when it was installed.

The first thing you’ll see is a message about “Installing VS Code Server” (the c7d83e57… number is the version of the VS Code Server that matches the client-side tools you just installed). VS Code is installing a small server on the Linux side that the desktop VS Code will then talk to. That server will then install and host extensions in WSL, so that they run in the context of the tools and frameworks installed in WSL. In other words, your language extensions will run against the tools and frameworks installed in WSL, not against what is installed on the Windows side, as it should for the proper development experience.

The next thing that happens is VS Code will start and open the helloWorld folder. You may see a quick notification telling you that VS Code is connecting to WSL, and you may be prompted to allow access to the Node.js-based server.

Now, when you hover over hello.py. you get the proper Linux path.

Integrated Terminal

Run Terminal New Terminal ( ⌃` (Windows, Linux Ctrl` ) ) to open a new terminal instance.

You’ll start a new instance of the bash shell in WSL, again from VS Code running on Windows.

Tip: In the lower left corner of the Status Bar, you can see that you’re connected to your WSL: Ubuntu instance.

Edit and debug

Installing the Python extension (and additional tools)

Click on hello.py to open it for editing. You will be prompted with an extension recommendation, in this case to install the Microsoft Python extension, which will give you rich editing and debugging experiences. Go ahead and select Install and reload if prompted.

To prove that the extension is installed in WSL, open the Extensions view again ( ⇧⌘X (Windows, Linux CtrlShiftX ) ). You will see a section titled WSL: Ubuntu – Installed, and you can see any extensions that are installed on the WSL side.

install, windows, subsystem, linux

Upon reload, you’ll also get prompted telling you that the pylint linter is not installed. Linters are used to show errors and warnings in source code. Go ahead and select Install.

Now, when you edit your code, you get rich colorization and completions.

And when you save your file ( ⌘S (Windows, Linux CtrlS ) ), you’ll get linting errors and warnings on the file.

Debugging

With your tools set up, let’s take this one step further. Set a breakpoint on line 1 of hello.py by clicking in the gutter to the left of the line number or by putting the cursor on the line and pressing F9.

Now, press F5 to run your application. You will be asked how to run the application, and since this is a simple file, just choose Python File.

The app will start, and you’ll hit the breakpoint. You can inspect variables, create watches, and navigate the call stack.

Press F10 to step and you’ll see the output of the print statement in the debug console.

You get the full development experience of Visual Studio Code, using the Linux instance installed in WSL.

If you want to open another folder in WSL, open the File menu and choose Open Folder. You’ll get a minimal file and folder navigator for the Linux file system, not the Windows file system.

If you want to switch back to the Windows, select the Show Local option and you’ll get the standard Windows File Open dialog.

Ending your WSL connection

You can end your session in WSL and go back to running VS Code locally with File Close Remote Connection.

Congratulations

Congratulations, you’ve successfully completed this tutorial!

Next, check out the other Remote Development extensions.

Or get them all by installing the Remote Development Extension Pack.

[Solved] WSL Not Working After Upgrading to Windows 11

WSL is the Windows Subsystem for Linux and this WSL not working after upgrading to Windows 11 issue appears. If you are troubled by this problem, this article from MiniTool Partition Wizard will talk something about this error, and show some solutions.

Windows Subsystem for Linux (WSL) is part of the Windows operating system functionality that allows you to run Linux file systems, command-line tools, and GUI applications on Windows computers. However, many users reported that WSL does not work or does not start on Windows 11.

Well, how to fix WSL not working in Windows 11? Keep reading.

Running out of space on your Chromebook? How to free up space on Chromebook? This post would show you several ways to free up Chromebook storage.

install, windows, subsystem, linux

Fix 1: Enable Windows Subsystem for Linux

When users upgrade their systems to Windows 11, the WSL functionality will be disabled. So, just enable this feature and it will return to normal state.

Step 1: Press the Win S key and type Turn Windows features on or off and press the Enter button.

Step 2: Scroll down the screen and select Windows Subsystem for Linux and enable it.

Step 3: Now click on the OK button.

Wait a few seconds for the system files to be installed, and you will be prompted to restart your computer.

Fix 2: Enable Virtual Machine

Running Windows Subsystem for Linux (WSL) requires installing a virtual machine, which allows you to run multiple operating systems simultaneously using the same hardware. If Windows Subsystem for Linux is enabled, the next thing you need to check is whether the virtual machine is enabled. Proceed as follows:

Step 1: Press the Win S key and type turn Windows features on or off, then press the Enter button.

Step 2: Scroll down the screen and select Virtual Machine Platform and enable it.

Step 3: Now click on the OK button.

Wait a few seconds, you will be asked to restart your computer and check if the problem is resolved.

Fix 3: Enable Hyper-V

Hyper-V is a feature in the Windows operating system that allows the system to create virtual environments. If this feature is disabled on your system, you will not be able to start or create WSLs. Therefore, you need to enable Hyper-V.

In the Windows Features box, look for Hyper-V and enable it. After enabling the feature, restart your computer and check if it is fixed.

Can you stream Xbox Series X|S to PC? How to stream Xbox Series X|S to PC? Do you want to know the answer to them? Just read this post to know more.

Fix 4: Launch Windows Subsystem for Linux from the Microsoft Store

Sometimes users are unable to start WSL because of a glitch in the installed application. Therefore, you must update WSL from the Microsoft Store, and you can start Windows Subsystem for Linux (WSL) from the Microsoft Store. This way you not only get the latest updates and new features, but also troubleshoot issues.

Step 1: Press the Windows key and type Microsoft Store, then press Enter.

Step 2: Select Library from the lower left corner of the Apps screen.

Step 3: Select the Linux distribution app, such as Ubuntu, and click Launch.

Now, start WSL and check if the WSL not working in Windows 11 problem persists.

Fix 5: Repair Linux Distribution Application

Your Linux distribution application may be dealing with broken bugs, or it may be outdated which prevents you from using it properly. If this is the case, then you have two options to fix the problem: fix it or uninstall it and reinstall it. To repair the application, follow the steps prescribed below:

Step 1: Press the Windows I key to open Settings. Then select Apps.

Step 2: Click Apps Features or Installed Apps on the right side of the screen.

Step 3: Scroll down the screen and select the Linux distribution application.

Установка Ubuntu на Windows 11 с помощью WSL | WSL Install 2022 | Подсистема Linux на Windows 10

Step 5: Now click on the Repair button there. Then follow the on-screen instructions to complete the process.

Once done, you can launch WSL and check if the WSL not working in Windows 11 issue gets fixed.

How to see recently opened files in Windows 11? If you want to know the answer, this post is what you need.

| Denial of responsibility | Contacts |RSS