WSL2 Ubuntu on Windows

Published on

What WSL2 Ubuntu is, why it is useful on Windows, how to install it, and how to use it safely for Linux-oriented development and AI-assisted coding workflows.

Platforma

What is WSL2 and Why Use It?

Windows Subsystem for Linux 2 (WSL2) allows you to run a real Linux environment directly inside Windows without dual booting or maintaining a traditional virtual machine.

In practice, WSL2 provides a Linux kernel, Linux filesystem, Ubuntu and other Linux distributions, native package managers, shell scripting, automation, and command-line tooling while keeping Windows available for desktop applications, browsers, design tools, office software, and other Windows-native workflows.

For developers, WSL2 offers a practical way to use the same type of Linux environment commonly found on servers, cloud infrastructure, CI/CD systems, and modern development platforms, while continuing to work on Windows.

Main benefits

  • Linux development environment on Windows: Bash, SSH, Linux permissions, symbolic links, shell scripts, package managers, and CLI tools work in their intended environment.
  • Better compatibility with Linux-based development: many workflows are designed primarily around Linux servers and Linux tooling. WSL2 reduces differences between local development, CI/CD systems, and production deployments.
  • Cleaner separation: projects, dependencies, caches, shell configuration, credentials, and development tools can live inside a dedicated Ubuntu environment instead of being mixed with the personal Windows profile.
  • Fewer filesystem and path issues: Linux tooling avoids many Windows-specific edge cases involving drive letters, path separators, native binaries, and filesystem compatibility.
  • Convenient Windows integration: Windows remains available for graphical applications while Linux handles the development workflow.
Important:

This article focuses specifically on WSL2 Ubuntu as a Linux development environment running on Windows. WSL2 is an excellent choice for many development workflows, but it should be viewed as one tool in a broader development toolbox rather than a universal solution for every type of project.

Most general Ubuntu administration and development knowledge also applies to Ubuntu running inside WSL. For related Linux and Ubuntu topics, use the broader Ubuntu Wiki.

Installing WSL2 Ubuntu

Prerequisites

WSL2 is supported on Windows 11 and on modern versions of Windows 10.

If you are using Windows 10, WSL2 requires version 2004 (build 19041) or newer.

To check your Windows version:

Win + R
winver

If your system is older than the required version, update Windows before continuing.

  1. Open PowerShell as Administrator

    Open the Start Menu, search for PowerShell, right-click it, and select Run as Administrator.

  2. Install WSL2 and Ubuntu

    Run the following command:

    wsl --install

    This command will:

    • install WSL2,
    • install Ubuntu,
    • enable required Windows features,
    • request a system restart if necessary.
  3. Restart Windows

    Restart the computer if prompted.

  4. Verify Installed Distributions

    After the restart, open PowerShell again and verify that WSL is available:

    • Check WSL version:
      wsl --status

      A typical output should indicate:

      Default Version: 2
      Default Distribution: Ubuntu

      If Ubuntu was not installed automatically, it can be installed manually:

      wsl --install -d Ubuntu
    • Check Ubuntu version:

      To see all installed WSL distributions and their versions:

      wsl --list --verbose

      Example output:

      NAME      STATE    VERSION
      Ubuntu    Running  2
  5. Launch Ubuntu (and set up your environment)

    Open the Ubuntu application from the Start Menu.

    During the first launch, Ubuntu will ask you to create:

    • a Linux username,
    • a Linux password.

    This Linux user account is separate from your Windows account and will be used when working inside Ubuntu.

Recommended Project Location

Projects intended for Linux tooling should be stored inside the WSL filesystem, not on the mounted Windows disk.

Recommended

/home/<user>/projects/my-project
/home/<user>/code/my-project

Avoid for typical WSL development

/mnt/c/Users/<WindowsUser>/projects/my-project
/mnt/d/projects/my-project

Keeping projects inside the Linux filesystem typically provides better filesystem performance, fewer permission-related issues, fewer Linux/Windows compatibility problems, cleaner separation from personal Windows files, and more predictable behavior for development tools.

A common structure is:

/home/<user>/projects

Accessing WSL Files from Windows

WSL files are accessible directly from Windows Explorer through the special WSL network path:

\wsl$

For Ubuntu, the home directory is typically available as:

\wsl$\Ubuntu\home\<user>

This allows you to browse, copy, and inspect Linux files from Windows.

Visual Studio Code can also work directly inside WSL. From the Ubuntu terminal, open the current project with:

code .

When opened this way, VS Code runs in Remote WSL mode: the editor UI runs on Windows, while terminals, extensions, and development tools operate inside Ubuntu.

Using WSL2 with AI Coding Agents

Modern AI coding agents such as Claude Code, Codex, Gemini CLI, and similar tools can read files, modify source code, execute shell commands, install packages, inspect logs, and alter project configuration.

The question is therefore not whether an AI agent can modify your development environment, but how much of your system you allow it to access.

Why separation matters

A personal Windows account often contains:

  • browser sessions,
  • personal documents,
  • cloud credentials,
  • SSH keys,
  • API tokens,
  • production secrets,
  • communication tools,
  • financial or private information.

Mixing AI-assisted development directly into that environment may unnecessarily increase exposure.

Recommended principle

Give the AI agent broad access to the project. Do not give the AI agent broad access to your personal environment.

The goal is not to prevent the agent from doing useful work. The goal is to ensure that useful work happens inside a controlled workspace.

The most effective improvement for most developers

When discussing development security, it is easy to focus on advanced solutions such as virtual machines, endpoint protection platforms, privileged access workstations, network segmentation, or enterprise device management.

These approaches can provide additional protection, but they are often unnecessary or too complex for individual developers and small teams. For most users, the biggest practical improvement comes from something much simpler - Separate personal and development environments.

This is not only a security measure. It is also an effective way to keep projects, tools, credentials, browser sessions, and AI agents organized by purpose.

Use separate Windows accounts

One of the simplest and most effective ways to achieve this separation is to use dedicated Windows accounts for different purposes.

Windows account: personal
  Personal files
  Email
  Banking
  Everyday browsing

Windows account: ai-agents
  WSL2 Ubuntu
  Development projects
  AI coding agents

This provides:

  • separation of personal and development files,
  • separation of browser sessions,
  • separation of credentials,
  • separate WSL installations,
  • reduced exposure of personal information,
  • cleaner development environments.

For many individual developers, using separate Windows accounts provides a larger practical security improvement than installing additional security software.

A practical recommendation

If you plan to use AI coding agents regularly, consider creating a dedicated Windows account specifically for development work.

The account can remain a standard, non-administrator user and may contain little more than:

  • WSL2 Ubuntu,
  • development tools,
  • project repositories,
  • AI coding agents.

This approach is easy to implement, easy to maintain, and provides a strong improvement in both organization and security.

Start with a fresh Ubuntu installation

If a personal WSL2 Ubuntu installation already exists, it is usually safer not to reuse it for AI-assisted development.

An older WSL environment may already contain:

  • SSH keys,
  • cloud credentials,
  • npm tokens,
  • shell history,
  • API keys,
  • Wrangler login state,
  • .env or .dev.vars files,
  • database credentials.

A safer approach is:

Windows account: ai-agents
  Fresh Ubuntu installation

WSL distributions are tied to the Windows account that installed them. A newly created Windows account does not automatically gain access to Ubuntu distributions belonging to another Windows account.

In practice, the dedicated account may function almost entirely as a launcher for WSL Ubuntu. After signing in, development work takes place inside Ubuntu through Windows Terminal or VS Code.

Understand the limits of WSL

WSL improves separation. WSL does not provide absolute isolation.

For most development workflows, WSL2 offers an excellent balance between convenience and separation. However, it should not be considered a full security sandbox.

If stronger isolation is required, a dedicated virtual machine provides a higher level of separation.

Practical Summary

  • WSL2 provides a real Linux environment directly on Windows.
  • Development environments become closer to Linux-based production systems.
  • Projects should be stored inside the Linux filesystem, not under /mnt/c for typical WSL development.
  • WSL files are accessible from Windows through \\wsl$.
  • VS Code can work directly inside Ubuntu through Remote WSL.
  • A dedicated Windows account is recommended for AI-assisted development.
  • Existing personal WSL installations should not be reused for AI agents if they contain credentials or private configuration.
  • WSL improves separation but should not be considered a full security sandbox.
  • A virtual machine provides stronger isolation when required.
Vrealmatic consulting

Need help with a secure development setup?

We can help you design a practical Windows, WSL, cloud, and AI development workflow.

Contact Us