Whenever I try to call the following command: "notepad /etc/bash.bashrc" from Windows WSL I get an error

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 ?


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:

  • What's the easiest way to run GUI apps on Windows Subsystem for Linux as of 2018?

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.