如何在 Windows 上的 Ubuntu 上从 Bash 访问 Windows 文件夹

Ser*_*ace 179 bash shell windows-10 windows-subsystem-for-linux

在 Windows 应用程序上的 Ubuntu 上的 Bash 上,我只有

root@localhost:~# ls -a
    .bash_history  .bashrc  .profile
Run Code Online (Sandbox Code Playgroud)

如何访问所有 Windows 文件夹,如文档、下载等?

Ben*_*n N 291

您将在 Bash 环境中找到 WindowsC:\结构/mnt/c/

因此,我的 Documents 文件夹位于/mnt/c/Users/Ben/Documents/.

  • 你在 `~` 目录中,你在 Bash 环境中的家,它不是根 (`/`)。如果你先做了`cd /`,你就会看到`mnt`。 (5认同)

Kei*_*OYS 34

或者

  1. 按住Shift同时右键单击您想要的Windows目录
  2. 选择“在此处打开 PowerShell 窗口

PowerShell 上下文菜单

  1. 进入 PowerShell 后,键入 bash

您将能够直接使用任何 Bash 命令来对该 Windows 目录中的文件和文件夹进行操作。通过使用这种方法,您不必手动cd进入您的目录,尤其是当您有一个根深蒂固的目录要访问时。


自 Windows 10 1809 起更新:

以上仍然有效,但现在有一个更简单的方法。

  1. 按住Shift同时右键单击您想要的Windows目录
  2. 选择“在此处打开 Linux shell