Notepad can open any file since that file is in a common Windows directory. I dislike editors like Vi and Vim, so I'd like to open files with notepad or even notepad++, but it seems that notepad or notepad++, when they are called from WSL, can't access any file inside Linux root ('/') tree. Is there any way to do that ?
-
Related: Any way to use Visual Studio Code editor instead of nano/vim/emacs to edit files? – Eliah Kagan Aug 13 '19 at 03:06
2 Answers
NEVER EVER Use a Windows Application to change a WSL file. YOU WILL CORRUPT YOUR DATA.
If you have Windows update 1903 installed (March 2019) you can use Windows File Explorer to access WSL files. However WSL must be running first.
If you want a GUI to edit files try gedit
after installing sudo apt install ubuntu-desktop
. See this for more information:

- 102,282
-
Thanks @WinEunuuchs2Unix, but despite I've updated my Windows to update 1903, when I call "explorer.exe ." from my home directory in WSL, the Windows Explorer opens, though it shows the Documents folder instead of my home directory in WSL. I'll try to install ubuntu-desktop. Hope, at least, this works. – Renato Aug 13 '19 at 13:26
-
Please note you need to install VcXsrv as the link describes before installing Ubuntu Desktop GUI. – WinEunuuchs2Unix Aug 13 '19 at 15:19
-
I figured out where the Ubuntu directory tree is. It's in "C:\Users<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\etc". Wow! It was only possible because I used Windows Explorer search inside my "c:\Users" folder. I think Microsoft doesn't like we have access to that directory tree anymore. Anyway, I'll install VcXsrv and then Ubuntu Desktop. Thanks again, @WinEunuuchs2Unix! – Renato Aug 14 '19 at 02:03
You should NEVER attempt to access your WSL files through the AppData folder. It is hidden there because modifying it can corrupt your Linux distro.
The correct way is by accessing \\wsl$
through Windows Explorer either by typing it directly into the address bar or clicking the "Linux" folder in your Explorer sidebar (For example mine lists OneDrive, This PC, Network, and Linux in my sidebar). You can also type explorer.exe .
into bash and it will open Windows Explorer up to your current directory.
Because WSL has access to Windows paths, programs like notepad.exe, explorer.exe, calc.exe, etc. should all be accessible directly through Linux commands.
echo "Hello, World!" > hello.txt
notepad.exe hello.txt
This opens hello.txt using the Windows notepad. From there you can add the text "Hello, WSL!" in notepad and save. Now if you look at the contents in bash again, you can see it updated the file.
cat hello.txt
Hello, World!
Hello, WSL!
To make these even more convenient you can create aliases for them!
alias notepad=notepad.exe
alias explorer=explorer.exe
These can be saved in your .bash_aliases
file.
Now you can use notepad hello.txt
to open a text file from bash using the Windows notepad.

- 111