如何在 WSL-Ubuntu 上的 bash 中导航到 C 驱动器?

Dan*_*ing 37 command-line windows-subsystem-for-linux

我已经在 Windows 10 上的 Windows 功能上的 Ubuntu 上安装了 bash,我想在我的C:\驱动器上更改此路径的目录:

C:/wamp64/www 
Run Code Online (Sandbox Code Playgroud)

我该怎么办 ?

use*_*186 66

C:\在 Windows 中是/mnt/c/在 WSL Ubuntu 中

在 Windows Subsystem for Linux (WSL) 中,C:\驱动器安装为/mnt/c/D:\安装为/mnt/d/等。因此,C:/wamp64/www应在/mnt/c/wamp64/www。尝试:

cd /mnt/c/wamp64/www
Run Code Online (Sandbox Code Playgroud)

在 Ubuntu 终端中转到该文件夹​​。注意,第一/之前mnt,记住,在Ubuntu文件和文件夹的名称是区分大小写的。所以wamp64, WAMP64, wAmP64, 和WaMp64是 4 个不同的文件夹!有关使用区分大小写的更多信息,请参阅https://superuser.com/questions/1116625/how-can-i-access-case-sensitive-paths-on-windows-created-with-bash-on-ubuntu-on WSL 中的文件名。

背景资料 /mnt

不熟悉 Ubuntu(一般为 Linux)的 Windows 用户可能想知道:

代表什么/mnt

在 Linux 中,几乎所有东西都是文件或文件夹。/mnt是一个文件夹,/mnt/c是一个文件夹c里面叫的文件夹/mnt

在 Linux 分区中(Windows 称它们为“驱动器”以混淆我们)安装在通常称为“安装点”的文件夹中。因此,在 WSL 中,“C 驱动器”安装在c文件夹内的/mnt文件夹中。/mnt是一个文件夹,在其中创建其他文件夹以安装各种分区。请参阅下面与 mnt 相关的链接。

参考:

https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/

https://superuser.com/questions/1066261/how-to-access-windows-folders-from-bash-on-ubuntu-on-windows

mnt

https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/mnt.html

希望这可以帮助

  • @YousefAltaf 在 Linux 中几乎所有东西都是文件或文件夹。`/mnt` 是一个文件夹,`/mnt/c` 是文件夹`/mnt` 内一个名为`c` 的文件夹。分区(Windows 称它们为“驱动器”以混淆我们)在 Linux 中安装在文件夹中。因此,“C 盘”安装在`/mnt` 文件夹内的`c` 文件夹中。[`/mnt`](http://www.linfo.org/mnt.html) 是一个文件夹,其中创建了其他文件夹,用于安装各种分区。 (2认同)