How to translate the wslpath /home/user/ to windows path

user504909 picture user504909 · Nov 26, 2018 · Viewed 7.9k times · Source

I use Linux subsystem of windows 10(windows 10 version 1803)

I can use command line:

user@laptop:~$ wslpath -w /c/
C:\

But when I try to use

user@laptop:~$ wslpath -w ~
wslpath: /home/user: Result not representable

Even I use:

user@laptop:~$ wslpath -w /home/user
wslpath: /home/user: Result not representable

why? how to translate the /home/user to windows path?

my home folder path in windows is C:\Users\winuser\AppData\Local\lxss\home

I expect some command line can give me return that string.

Answer

Rich Turner picture Rich Turner · Nov 29, 2018

Updated guidance for users of Windows 10 1809 or later:

In Windows 10 1809, we (finally) shipped filesystem integration allowing you to access the files in your WSL distros from Windows via the \\wsl$ UNC path:

enter image description here

If you're interested in the details behind how this works, please visit this blog post: https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/

This now allows wslpath to provide a Windows-accessible path to files within your distro's filesystem:

enter image description here

In the up-coming Windows 10 May 2020 Update (2004), you won't have to remember the somewhat obscure \\wsl$\ UNC path - instead you'll just click on the Tux (Linux penguin) icon in your File Explorer:

enter image description here

Warning for WSL1 users:

Do not try to spelunk to the %localappdata%\lxss\... folders containing your WSL1 Linux files from Windows - there be dragons!

Please read this post: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

This guidance has not, and will not change, though it will become less important over time: In particular, WSL2 does not use %localappdata%\lxss - instead it stores your linux files within EXT4 formatted VHDX files delivering near-native IO performance for the distro's local filesystem.