首页  >  文章  >  系统教程  >  如何在 Windows 10 和 Windows 11 中访问 Linux (WSL) 文件

如何在 Windows 10 和 Windows 11 中访问 Linux (WSL) 文件

WBOY
WBOY原创
2024-07-27 01:46:031009浏览

Windows 10's May 2019 Update introduced an easy, safe, and officially supported way to access and work with your Linux files from within File Explorer and other applications. Here's how to get at your Windows Subsystem for Linux (WSL) files.

Unlike previous methods, this is a safe way to work with Linux files! Windows does some magic in the background, making it possible to edit your Linux files from Windows applications without causing file permission issues. You still shouldn't modify the underlying files at their real location on your system.

It doesn't matter if you use WSL1 or WSL2. These commands all function exactly the same way.

Open WSL Files from Terminal

There are two ways to access your Linux files. First, the easy one. From within the Windows Subsystem for Linux environment you want to browse, run the following command:

explorer.exe .

This will launch File Explorer showing the current Linux directory—you can browse the Linux environment's file system from there.

How to Access Your Linux (WSL) Files in Windows 10 and Windows 11Open the WSL Directory in File Explorer Directly

You can also access them directly at the wsl$ path. In File Explorer or any other Windows application that can browse files, navigate to the following path:

wsl$

You'll see the folders for all your installed Linux distributions, which are exposed as if they were network shares. For example, Ubuntu 22.04 is usually available at wsl$Ubuntu-22.04.

Feel free to create a shortcut to this folder—for example, you could drag it to the Quick Access section in File Explorer's sidebar.

How to Access Your Linux (WSL) Files in Windows 10 and Windows 11

Again, you can modify these files normally as if they were any other type of file on your system. Modify files with Windows tools (Notepad even supports Unix line endings!), create new files in the Linux folders, delete files, or do anything else you like. Windows will ensure nothing goes wrong and the file's permissions are updated properly.

以上是如何在 Windows 10 和 Windows 11 中访问 Linux (WSL) 文件的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn