Linux – the home directory on Windows Subsystem for Linux

bashwindows 10windows-subsystem-for-linux

When I start bash on Windows Subsystem for Linux, it drops me in the directory

/mnt/c/Users/<username>

When I ls this directory, I see the directories Desktop, Documents, etc. that I can see are in C:\Users\<username> using the Windows File Explorer. Since this is where the bash program started, I expected this is my home directory, but when I type either cd or cd ~ I am brought to

/home/<username>

which contains my .bashrc, .profile etc. file which I would expect to find in my home directory in a Linux box. Moreover, entering cd ../.. from here I can see the directories bin, etc and so on, again as expected on a Linux box.

I have two questions regarding all this:

  1. What exactly is /mnt/c/Users/<username> compared with C:\Users\<username>? It seems they are one in the same—so what is /mnt/c/?
  2. How can I view the files in /home/<username> using the Windows File Explorer? Not that I'd really ever want to—I'm just trying to get a feel for how Windows is organizing this Subsystem for Linux thing.

Best Answer

In the latest versions [2020], the file system is accessed from:

# \\wsl$\<Distribution>:

\\wsl$\Ubuntu

Previously, as of 2018, The current path is related to which distribution you have installed from the Microsoft Store rather than one global path; for Ubuntu, it was located at:

%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

Other distributions should be (to be confirmed) in a similar location under their respective folders within:

%LOCALAPPDATA%\Packages\