Where is WSL located on my computer?

Windows Subsystem for Linux (WSL) is a powerful feature in modern versions of Windows that enables users to run a GNU/Linux environment directly on their Windows machine, without the need for a virtual machine or dual-boot setup. As WSL gains popularity among developers and IT professionals, many users wonder where exactly WSL resides on their machine. Understanding WSL’s location not only helps with better system management but also with tasks like data backups, performance optimization, and tech troubleshooting.

When referring to “where WSL is located,” we usually mean the filesystem, actual executable files, and kernel components. Let’s break down the different parts and locations associated with WSL.

1. Where are WSL Files Stored?

WSL distributions are stored as virtual disk images, typically in a hidden folder within your user profile’s AppData directory. By default, you will find the root filesystem for each installed Linux distribution in:

C:\Users\YourUsername\AppData\Local\Packages

Inside this directory, each WSL distribution is stored under its own folder. For example:

  • C:\Users\YourUsername\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc

Within such a distribution folder, you’ll find a LocalState directory, which contains the VHDX file—essentially the virtual disk where the Linux file system is stored:

  • ext4.vhdx

This file grows dynamically and includes all the data stored in your WSL environment, such as installed software, configuration files, and user data.

2. Accessing the Linux Filesystem from Windows

While you can technically browse to the VHDX location and even mount it with tools like Disk Management, Microsoft provides a more user-friendly way to access WSL files. Since Windows 10, users can simply navigate to:

\\wsl$

in File Explorer or through the Run dialog (Win + R). This path gives you access to the Linux root filesystem for each installed distribution.

For example:

  • \\wsl$\Ubuntu\home\yourusername

Note: Using the \\wsl$ path is the safest way to read and write files between Windows and WSL. Direct modifications of files inside the VHDX from Windows can lead to data corruption and is strongly discouraged.

3. Location of the WSL Executables

WSL itself is integrated into Windows and its core components reside in the Windows System folders. The main executable responsible for launching WSL is simply called:

  • wsl.exe

This executable is typically located in:

  • C:\Windows\System32\wsl.exe

If you’re using WSL 2, there is also a custom Linux kernel involved. This component is usually downloaded and updated through Windows Update, and its binary can be found in:

  • C:\Windows\System32\lxss\tools

The WSL service also leverages features of the Hyper-V virtualization stack for WSL 2 functionality, though it does not require Hyper-V to be fully enabled like a traditional VM would.

4. Using PowerShell to Locate Installed Distributions

If you want to list all installed WSL distributions and see their installation paths, you can use PowerShell:

wsl --list --verbose

This command gives you valuable information such as the distribution name, state (Running or Stopped), and version (WSL 1 or WSL 2). For more advanced file management, you can also use:

Get-AppxPackage *Linux* | Select Name, InstallLocation

This retrieves the full path of each installed Linux distribution on your machine.

5. Managing Disk Space and Backups

Knowing where WSL is located becomes crucial when managing disk space and performing backups. The ext4.vhdx file can grow significantly over time, especially with active development environments. To reduce its size, Microsoft provides a compact option:

wsl --shutdown
Optimize-VHD -Path "C:\Path\To\ext4.vhdx" -Mode full

This PowerShell command will reduce the footprint of the virtual disk, helping you reclaim valuable storage space.

Conclusion

WSL may appear as a seamless integration with Windows, but under the hood, it involves a complex architecture of virtual disks, executables, and kernels. Understanding where WSL is located on your computer gives you more control over system resources, file access, and maintenance practices. By using trusted paths and proper tools like the \\wsl$\ share and PowerShell commands, you can efficiently manage your WSL environments without compromising system stability or data integrity.