Install Windows Subsystem for Linux (WSL)

3 min read 4 months ago
Published on Apr 22, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

How to Install Windows Subsystem for Linux (WSL)

  1. Check Your Operating System Version:

    • Open the Start menu and search for "System Information."
    • Check the OS name and version. Ensure you are running Windows 10 or Windows 11.
  2. Choose a Linux Distribution:

    • For beginners, Ubuntu or Linux Mint Cinnamon is recommended.
    • For intermediate users, Debian 12 Bookworm is suggested.
  3. Activate Windows Subsystem for Linux (WSL):

    • Open the Start menu and search for "Turn Windows features on or off."
    • Activate "Virtual Machine Platform" and "Windows Subsystem for Linux."
    • Click "OK" and save your work. Restart your computer.
  4. Install WSL:

    • Open Command Prompt (CMD) by searching for it in the Start menu.
    • Type wsl --install and press Enter.
    • Follow the prompts to complete the installation.
  5. Update WSL:

    • Use the command wsl --update to ensure you have the latest version.
    • Confirm the update by entering 'yes.'
  6. Install a Linux Distribution:

    • Check available distributions online by running wsl --list --online.
    • Choose a distribution (e.g., Ubuntu) and install it using wsl --install -d <distribution_name>.
  7. Explore the Linux Environment:

    • Access the Linux environment by opening the Linux folder.
    • Navigate through directories using commands like cd <directory> and list files with ls.
  8. Access Linux through WSL App:

    • Search for "WSL" in the Start menu to open the WSL app, providing access to the Linux terminal.
  9. Use Windows Terminal:

    • Search for "Terminal" in the Start menu to open the Windows Terminal app.
    • Switch between different terminals, including Ubuntu, within the same window.
  10. Verify Ubuntu Version:

    • In the Ubuntu terminal, run lsb_release -a to confirm the Ubuntu version.
  11. Update Ubuntu:

    • Run sudo apt update and sudo apt upgrade to update Ubuntu packages.
  12. Access WSL through PowerShell:

    • Open PowerShell and run wsl to access WSL through the command line.
  13. Understand WSL 1 vs. WSL 2:

    • WSL 1 uses a translation layer for compatibility, while WSL 2 runs a full Linux kernel for better performance.
    • Check and switch to WSL 2 if needed by following Microsoft's guide.
  14. Completion:

    • Congratulations! You have successfully installed and set up Windows Subsystem for Linux (WSL) on your Windows machine.

Next Steps:

  • In the following videos, learn about using Git, GitHub, and VS Code within your WSL environment for a seamless coding experience.