Windows 10’s April 2019 Update brings a long-awaited feature: Support for easily accessing, viewing, and even modifying Windows Subsystem for Linux (WSL) files from File Explorer or via the command line.
Windows 10的2019年4月更新带来了期待已久的功能:支持通过File Explorer或通过命令行轻松访问,查看甚至修改Windows Linux子系统(WSL)文件。
Previously, it was possible to find your Linux files in your AppData folder, but Microsoft warns against that. Modifying files here would break things. Now, there’s an easier, official way to access these files with Windows tools—without the risk of breaking anything!
Microsoft’s Craig Loewen explains how it works: Rather than accessing these files directly, Windows runs a Plan 9 server as part of the WSL software in the background. Windows 10 has “a Windows service and driver that acts as the client and talks to the Plan9 server.” That server translates your file operations and handles Linux metadata such as file permissions, ensuring everything works properly even when you access a file with a Windows tool. But that’s just the complicated stuff that happens in the background, and you don’t have to think about it.
微软的Craig Loewen解释了它的工作原理:Windows而不是直接访问这些文件,而是在后台运行作为WSL软件一部分的Plan 9服务器。 Windows 10具有“充当客户端并与Plan9服务器对话的Windows服务和驱动程序。” 该服务器可以转换文件操作并处理Linux元数据(例如文件权限),即使在使用Windows工具访问文件时,也可以确保一切正常。 但这仅仅是在后台发生的复杂事情,您无需考虑。
You can open a File Explorer window directly in the current directory from within a Linux shell environment. Just type the following command into the Bash shell:
Microsoft may change how this works in the future. But, for now, you can also type following path into an Explorer window to access a Linux distribution’s files:
This also works from the command line, of course. In PowerShell or the Command Prompt, the command cd \\wsl$\Debian\ changes to the root directory of your installed Debian system.
Windows Subsystem for Linux users have wanted this feature for a long time. Back in 2016, Microsoft’s Rich Turner wrote that he had to warn people not to access their Linux files in File Explorer at least two or three times per day. Now, there’s finally a way to work with these files without the risk of breaking something.