Access WSL Linux Files from Windows 10

Windows 10 version 1903 "April 2019 Update" comes with a number of interesting changes and improvements made to the WSL feature. These include additional distros in the Store, the ability to browse WSL files from File Exporer, and more.

The ability to run Linux natively in Windows 10 is provided by the WSL feature. WSL stands for Windows Subsystem for Linux, which initially, was limited to Ubuntu only. Modern versions of WSL allow installing and running multiple Linux distros from Microsoft Store.

Linux Distros Microsoft Store Windows 10

After enabling WSL, you can install various Linux versions from the Store. You can use the following links:

  1. Ubuntu
  2. openSUSE Leap
  3. SUSE Linux Enterprise Server
  4. Kali Linux for WSL
  5. Debian GNU/Linux

and more.

Tip: You can use this tool to repair Windows problems and improve performance of the OS.

With Windows 10 version 1903 "April 2019 Update" you can easily access all the files in your Linux distros from Windows. As of this writing, this feature is implemented in Windows 10 build 18836. It is on its way to the 19h1 branch, so we will see it with the next build. Here is how it can be done.

To access WSL Linux Files from Windows 10, do the following.

  1. Enable the WSL feature.
  2. Install some distro, e.g. Ubuntu, and start it.
  3. While in a directory on a Linux FS, type explorer ..
  4. This will open a File Explorer window, located inside of your Linux distro.

Access Linux Files In Windows 10

From there you can access whatever Linux files you like, just like you would any other file through File explorer. This includes operations such as: dragging files back and forth to other locations, copy and paste, and even using custom context menu entries added by Notepad++, VSCode, and other software.

File Explorer shows the distro files as a virtual network share under the path \\wsl$\<running_distro_name>\.

WSL Network Share

The WSL team is actively investigating ways to improve the discoverability of Linux files inside of File Explorer. The progress of their work can already be seen in Windows 10 Build 18836 that shows WSL/Linux File System in File Explorer.

Access Linux Files in Command Line

In addition to File Explorer, you can use the classic Command Prompt, and PowerShell tools to access your Linux files. Similarly, you need to navigate to \\wsl$\{distro name}\ where {distro name} is the name of a running distro.

WSL In PowerShell

Known issues

This is a new feature, and some pieces of it may not work perfectly. Here are some known issues that we want to make you aware of when using this feature:

  • As of right now, the distros files will only be accessible from Windows when the distro is running. Developer are going to add support for non-running distros in a future update.
    Since the 9P file server runs inside of each distro, it is only accessible when that distro is running. The team is looking into ways to help resolve this.
  • Accessing Linux files is treated the same as accessing a network resource, and any rules for accessing network resources will still apply
    e.g: When using CMD, cd \\wsl$\Ubuntu\home will not work (as CMD does not support UNC paths as current directories), however copy \\wsl$\Ubuntu\home\somefile.txt C:\dev\ will work
  • The old rules still apply, you should NOT access your Linux files inside of the AppData folder!
    If you try to access your Linux files through your AppData folder, you are bypassing using the 9P server, which means that you will not have access to your Linux files, and you could possibly corrupt your Linux distro.

Note: A 9P server is a server that contains protocols that support Linux metadata, including permissions. The WSL init daemon now includes a 9P server. There is a Windows service and driver that acts as the client and talks to the 9P server (which is running inside of a WSL instance). Client and server communicate over AF_UNIX sockets, since WSL allows interop between a Windows application and a Linux application using AF_UNIX.

Source: Microsoft

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.