gpt4 book ai didi

bash - 如何将 wslpath/home/user/转换为 windows 路径

转载 作者:行者123 更新时间:2023-12-03 23:21:33 34 4
gpt4 key购买 nike

我使用 Windows 10 的 Linux 子系统(Windows 10 版本 1803)

我可以使用命令行:

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

但是当我尝试使用
user@laptop:~$ wslpath -w ~
wslpath: /home/user: Result not representable

即使我使用:
user@laptop:~$ wslpath -w /home/user
wslpath: /home/user: Result not representable

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

我在 Windows 中的主文件夹路径是 C:\Users\winuser\AppData\Local\lxss\home
我希望一些命令行可以让我返回那个字符串。

最佳答案

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

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

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/



这现在允许 wslpath为您的发行版文件系统中的文件提供 Windows 可访问的路径:

enter image description here

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

enter image description here

WSL1 用户警告:

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

请阅读此帖: 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 文件中,为发行版的本地文件系统提供接近 native 的 IO 性能。

关于bash - 如何将 wslpath/home/user/转换为 windows 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53474575/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com