Skip to main content

Command Palette

Search for a command to run...

Mount WSL file system in Windows to enable access via cmd.exe or PowerShell

Published
1 min read
Mount WSL file system in Windows to enable access via cmd.exe or PowerShell
A

I am working as a Cloud Engineer with experience in DevOps, automation, CICD, build pipelines, jenkins pipelines, version control, shell scripting, python automation, golang automation, cloud services (AWS, OCI, Azure), containers and microservices, terraform, ansible.

The windows command prompt does not understand UNC (Universal Naming Convention) paths which starts with \\ rather than a drive letter, so mapping a UNC path to a drive will convert it to a drive letter path. Follow the below instruction to do the same:

1. Get the wsl destro version (run command in cmd.exe/powershell)

\> wsl -l

Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)

2. Mount the wsl filesystem as a network drive by below command

net use <drive-name>: \\wsl$\<destro_name>

example:

\> net use z: \\wsl$\Ubuntu-20.04

The drive Z: will be visible as a network drive in windows file system. At above command wsl$ is a special hostname that tells Windows to connect to WSL Ubuntu-20.04 is a distribution name under WSL.

Now you can access/explore wsl filesystem wiith cmd.exe/powershell

Z:

Thanks for Stopping by. Cheers…!