Getting Started with Windows Subsystem for Linux: A Beginner’s Guide

Contents


    Windows Subsystem for Linux (WSL) is a feature of Windows 10 and later that allows you to run a Linux environment directly on Windows without the need for a virtual machine. It’s perfect for developers, and those who want to leverage a Unix-based development environment on Windows. Here’s how you can get started with WSL.

    Step 1: Enable WSL

    Windows 10

    1. Open PowerShell as Administrator:

      • Press Win + X to open the Power User menu.
      • Select "Windows PowerShell (Admin)".

    2. Enable WSL:

      • Type the following command and press Enter:
        dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

    3. Enable Virtual Machine Platform:

      • Type the following command and press Enter:
        dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

    4. Restart Your Computer.

    Windows 11

    1. Open Settings:

      • Press Win + I to open Settings.

    2. Access the Apps Menu:

      • Navigate to "Apps" > "Optional features".
      • Under "Related settings", click on "More Windows features".

    3. Enable WSL:

      • Check "Windows Subsystem for Linux" and "Virtual Machine Platform".
      • Click "OK" and restart if prompted.

    Step 2: Install a Linux Distribution

    1. Open Microsoft Store:

      • Search for "Microsoft Store" in the Start menu.

    2. Choose a Linux Distribution:

      • Search for "Linux" and select your preferred Linux distribution, such as Ubuntu, Debian, or Kali.

    3. Install the Distribution:

      • Click "Get" or "Install" to begin downloading and installing the distribution.
      • Once installed, click "Launch" to initialize your Linux environment.

    Step 3: Set Up Your Linux Environment

    1. Create a User Account:

      • When you first launch the distribution, you’ll be prompted to create a user account and password.

    2. Update Package Lists:

      • Open your Linux terminal and enter the following command to update your package lists:
        sudo apt update

    3. Upgrade Packages:

      • To upgrade installed packages to the latest version, use:
        sudo apt upgrade

    Step 4: Start Using WSL

    1. Access WSL:

      • You can launch your installed Linux distribution from the Start menu or by typing its name into the Windows Terminal.

    2. Install Additional Software:

      • To install software, use the package manager provided by your distribution (e.g., apt for Ubuntu):
        sudo apt install <package_name>

    3. Interoperability with Windows:

      • Access your Windows files from within your Linux environment at /mnt/c/ and use Linux commands to navigate and manage them.

    4. Switch Between Versions:

      • To switch to WSL 2, if desired, use the command:
        wsl --set-version <distro_name> 2

    Step 5: Further Configuration (Optional)

    • Customize Your Shell: Install tools like Zsh or customize your Bash prompt for a better experience.
    • Shared Environment: Set up shared environment variables and configurations between Windows and Linux.
    • Explore Development Tools: Install development tools and editors like Visual Studio Code for seamless integration with WSL.

    Troubleshooting

    • Verify Installation:

      • Check the WSL version with:
        wsl -l -v
    • Update WSL:

      • Make sure you have the latest WSL update:
      • Check for updates via Windows Update or use the latest Windows Insider build.

    By following these steps, you should have a fully functional Linux environment on your Windows machine, ready for development or exploration of Linux-based tools and commands. Enjoy!

    Updated on May 28, 2025
    Was this article helpful?

    Leave a Reply

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