How to Set Up Windows Subsystem for Linux (WSL) on Windows 11

How to Set Up Windows Subsystem for Linux (WSL) on Windows 11

Windows Subsystem for Linux (WSL) allows you to run a Linux distribution directly on Windows 11 without the overhead of a virtual machine. This guide will walk you through the steps to install and set up WSL on your Windows 11 machine, ensuring you can leverage the power of both Windows and Linux for development.

Step 1: Enable WSL

To enable WSL on Windows 11, follow these steps:

  1. Open the Start menu and search for "Windows PowerShell". Right-click on Windows PowerShell and select "Run as administrator".
  2. In the PowerShell window, enter the following command to enable the WSL feature:
    wsl --install
  3. This command will install WSL and set WSL 2 as the default version. If you wish to install a specific Linux distribution, use:
    wsl --install -d 

    Replace <DistributionName> with the name of the Linux distro you want to install (e.g., Ubuntu, Debian).

Step 2: Set Up Your Linux User Info

After the installation, you will be prompted to create a user account and password for your Linux distribution. Follow the on-screen instructions to complete this step.

Step 3: Update and Upgrade Packages

To ensure your Linux distribution is up to date, open your WSL terminal and run the following commands:

sudo apt update
sudo apt upgrade

Step 4: Install and Customize Windows Terminal

Windows Terminal is a powerful tool that can host multiple command lines, including PowerShell, Command Prompt, and WSL. Install Windows Terminal from the Microsoft Store and customize it to your preferences:

  1. Open the Microsoft Store and search for "Windows Terminal".
  2. Click "Install".
  3. Once installed, open Windows Terminal and configure your settings by navigating to the settings menu (Ctrl + ,). You can customize themes, color schemes, and startup actions.

For more details on customization, visit the Windows Terminal customization guide.

Step 5: Set Up a Development Environment

To create an effective development environment in WSL, follow these steps:

  1. Install a code editor: Visual Studio Code is highly recommended for its seamless integration with WSL. Install it from the official website and add the Remote Development extension pack.
  2. Configure Git: Set up Git for version control by installing it in your WSL terminal:
    sudo apt install git

    Configure your Git credentials:

    git config --global user.name "Your Name"
    git config --global user.email "youremail@example.com"

    For more information, refer to the Git setup guide.

  3. Use Docker: If your projects require containerization, install Docker Desktop and enable the WSL 2 integration. Follow the instructions on the Docker documentation.

Step 6: Best Practices for File Storage

For optimal performance, store your project files within the WSL file system if you are working with Linux tools. Use the path:

\wsl$<DistroName>home<UserName><Project>

Storing files in the Windows file system might slow down performance when accessed from WSL. More details can be found in the WSL setup guide.

Additional Resources

By following these steps, you can set up WSL on your Windows 11 machine, creating a powerful and flexible development environment.

Leave a Comment

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