How To Change Directory Within Ubuntu WSL in Windows Format - Stack Overflow
How To Change Directory Within Ubuntu WSL in Windows Format - Stack Overflow
- Stack Overflow
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/
cd "C:\Path\To\Folder\"
Is there a way to change dir in Ubuntu WSL like can be done on Cygwin, using
Windows format?
$ 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
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.
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
cdw 'E:\username\folder1\folder2'
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.
https://stackoverflow.com/questions/62723987/how-to-change-directory-within-ubuntu-wsl-in-windows-format 3/3