本文介绍了如何将 wslpath/home/user/转换为 windows 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 windows 10 的 Linux 子系统(windows 10 version 1803)

我可以使用命令行:

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

但是当我尝试使用

user@laptop:~$ wslpath -w ~wslpath:/home/user: 结果不可表示

即使我使用:

user@laptop:~$ wslpath -w/home/userwslpath:/home/user: 结果不可表示

为什么?如何将/home/user 转换为 windows 路径?

我在 windows 中的主文件夹路径是 C:\Users\winuser\AppData\Local\lxss\home

我希望一些命令行可以让我返回那个字符串.

解决方案

针对 Windows 10 1809 或更高版本用户的更新指南:

在 Windows 10 1809 中,我们(最终)提供了文件系统集成,允许您通过 \\wsl$ UNC 路径从 Windows 访问 WSL 发行版中的文件:

如果您对其工作原理感兴趣,请访问此博客文章:

在即将发布的 2020 年 5 月 10 日 Windows 更新(2004 年)中,您不必记住有些晦涩的 \\wsl$\ UNC 路径 - 只需单击文件资源管理器中的 Tux(Linux 企鹅)图标:

WSL1 用户警告:

不要尝试从 Windows 探索包含 WSL1 Linux 文件的 %localappdata%\lxss\... 文件夹 - 有龙!

请阅读这篇文章:https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

本指南没有,也不会改变,但随着时间的推移它会变得不那么重要:特别是,WSL2 不使用 %localappdata%\lxss - 而是将您的 linux 文件存储在 EXT4 中格式化的 VHDX 文件,为发行版的本地文件系统提供接近原生的 IO 性能.

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.

解决方案

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:

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

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:

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.

这篇关于如何将 wslpath/home/user/转换为 windows 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:02