Step 7: Install WSL on Visual Studio Code and Upgrade to WSL2

The Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows, without the overhead of a traditional virtual machine or dual-boot setup. Installing WSL and upgrading to WSL2 enhances performance and supports full system call compatibility, which is crucial for development tasks.

Install WSL on Visual Studio Code

  1. Enable WSL on Windows:

    • Before installing a Linux distribution, you must enable the Windows Subsystem for Linux feature. Open PowerShell as Administrator and run:

      dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  2. Install Your Linux Distribution of Choice (Ubuntu):

    • Open the Microsoft Store and search for Ubuntu. Select the version you wish to install (e.g., Ubuntu 20.04 LTS) and click "Get" to install it.

    • Once installed, launch Ubuntu from the Start menu, and you'll be prompted to create a user account and password.

Upgrade to WSL2

  1. Ensure Your System Supports WSL2:

    • WSL2 requires Windows 10 version 1903 or higher. Ensure your Windows is up to date.

  2. Download the Linux Kernel Update Package:

  3. Set WSL2 as Your Default Version:

    • Open PowerShell as Administrator and run:

      wsl --set-default-version 2
    • This command sets WSL2 as the default version for any future Linux distribution installations.

  4. Verify Installation:

    • To confirm that WSL2 is installed and running, you can open your Linux distribution (e.g., Ubuntu) and run:

      uname -a
    • This command should display a Linux kernel version indicating that WSL2 is actively running.

Install WSL Extension in VSC

  • Navegate to "Extensions" tab in VSC and search for "WSL"; install the extension:

Last updated