Post

Find and Manipulate WSL Linux Files and Directories from Windows

Learn how to manipulate files on WSL Linux from Windows itself.

Find and Manipulate WSL Linux Files and Directories from Windows

Introduction

WSL Linux on Windows is simply mounted as a volume, so accessing the files and directories from Windows is possible.

It is not recommended to work directly on those, like for example openning Visual Studio Code Folder from there, but it is useful for simplicity.

Paths

The mounted path from WSL in windows is \\wsl.localhost\{Distribution}\. So if you have Ubuntu as the main distribution the path would be \\wsl.localhost\Ubuntu\home\{user}

Windows File Explorer

If you open the File explorer and go to \\wsl.localhost\Ubuntu\home\my-user you will see the wsl files in Windows File Explorer.

You can now navigate in the File Explorer as you would do with Windows. You can also save favorite paths for later if necessary.

Windows Terminal

If you’d like to cd (move to directory) from Windows (PowerShell, Nushell or Command Prompt) you can use the WSL Path to do it.

For example, from Windows PowerShell you could run

1
cd '\\wsl.localhost\Ubuntu\home\my-user'

When running cd from windows the wsl path must be escaped with single quotes '.

You can also do normal ops like copying a file from the wsl file system to windows f.e.:

1
cp my-file.txt C:/Users/my-user/Downloads/

Extras

Flow launcher

On Windows, Install Flow Launcher using scoop.sh.

1
2
scoop bucket add extras
scoop install extras/flow-launcher

When flow-launcher is running open it by pressing Alt+Space.

Then from your WSL Ubuntu distribution:

  • Install zsh
1
sudo apt install zsh -y
  • Install fd-find
1
sudo apt install fd-find

Finally, on Flow Launcher:

Then when opening Flow Launcher (Alt+Space) type wslf with space followed by the folder (f.e. project-go).

Then press Enter or Alt+F{Number} to open the File Explorer on the path selected.

This post is licensed under CC BY 4.0 by the author.