Search code examples
ubuntuwindows-subsystem-for-linuxcd

How to change directory within Ubuntu WSL in Windows format?


I have installed Cygwin on Windows. To change dir in Cygwin could be done in 2 ways:

In Unix format:

cd /cygdrive/path/to/folder/

In Windows format (surrounded by double quotes):

cd "C:\Path\To\Folder\"

Is there a way to change dir in Ubuntu WSL like can be done on Cygwin, using Windows format?

I get this error when trying on Ubuntu:

$ cd "C:\Path\To\Folder"
-bash: cd: C:\Path\To\Folder\: No such file or directory
$ cd "C:\Path\To\Folder\"
>

Solution

  • No. In order to access Windows files from WSL you need to visualize an Ubuntu VM that has mounted NTFS drives, so access needs to be using /mnt/c/... or /mnt/d/... etc.

    You need to use forward slashes as shown, since backward slashes (\) will be interpreted as escape characters within WSL.