Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

4/28/24, 5:33 PM How to change directory within Ubuntu WSL in Windows format?

- Stack Overflow

How to change directory within Ubuntu WSL in


Windows format?
Asked 3 years, 9 months ago Modified 1 year, 2 months ago Viewed 34k times

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

In Unix format:
10
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\"
>

ubuntu windows-subsystem-for-linux cd

Share Follow asked Jul 4, 2020 at 0:04


Ger Cas
2,238 2 20 53

4 Answers Sorted by: Highest score (default)

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/...

https://stackoverflow.com/questions/62723987/how-to-change-directory-within-ubuntu-wsl-in-windows-format 1/3
4/28/24, 5:33 PM How to change directory within Ubuntu WSL in Windows format? - Stack Overflow

14 etc.

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

Share Follow answered Jul 4, 2020 at 0:51


Cahit
2,514 19 23

1 Thanks for your answer Cahit. It would be nice to know who and why someone does a
downvote. – Ger Cas Jul 4, 2020 at 18:40

WSL stores your Windows drives in the /mnt folder, with the name of the drive as a
subfolder. For example your C:\ drive will be present at /mnt/c/ for you to use.
9
Keeping this in mind, you can swap to your specific folder like so:

cd /mnt/d cd /mnt/e/username/folder1/folder2

Share Follow answered Nov 8, 2020 at 16:16


Oscar Rangel
956 2 11 20

copied from sincostan, define this function in your .bashrc:

4 cdw() { local d=`wslpath "$1"`; cd "$d"; }

then , use like this:

cdw 'E:\username\folder1\folder2'

it seems there is no way to avoid inputing the quote marks.

Share Follow answered Jun 14, 2022 at 1:51


Max
105 6

https://stackoverflow.com/questions/62723987/how-to-change-directory-within-ubuntu-wsl-in-windows-format 2/3
4/28/24, 5:33 PM How to change directory within Ubuntu WSL in Windows format? - Stack Overflow

One more alternative, without defining the function, e.g. for temporary use:

2 cd `wslpath 'E:\example\path'`

Note that you need both backtick surrounding the wslpath command and its
parameter, and single quotes surrounding the windows path, to avoid unintentional
escaping of backslashes.

Share Follow answered Feb 15, 2023 at 14:12


panuv
31 2

https://stackoverflow.com/questions/62723987/how-to-change-directory-within-ubuntu-wsl-in-windows-format 3/3

You might also like