Understanding file location on Windows

I have been mucking around with SUSE server 12 (WSL) and can’t seem to comprehend one thing, why is it I can not see the /home/usrname/ location when I traverse my Windows folders, however if I type in Bash whereis /home/usrnameI can see the files listed. I guess it’s a little hard for me to fathom the concept of folder that is there but not. If someone is able to explain what’s happening and whether or not gaining access to the file structure is only limited to an instance of Bash?

Hello,

First of all, please let me give you the cautions:

There are two rules of thumb that you need to know:

  1. Using WSL (any flavor/distro/etc.) to manage files, etc. on the Windows Filesystem (i.e. not in WSL/Linux, or outside of WSL “/” ) is playing with fire.
  2. Using Windows to manage files, etc. on WSL/Linux (i.e. not in Windows or within WSL “/”) is playing with fire.

Also: Here is the official MS documentation about WSL, Windows, and Filesystems: https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/

But being as I love Linux, and that I believe responsible people can do whatever they want with their computer, here’s how to find the WSL root from Windows:

  1. Open a Windows Command Prompt as Administrator.
  2. Enter the following command:
CD   %LocalAppData%\\Packages
  1. Enter the following command:
DIR

…and by looking at the directory listing, you will be able to find the root directory of every WSL instance on your machine.

For example, on the Windows development environment that I use to test new WSL builds, here is what I see when I execute steps 2 and 3 in an Administrator Command Prompt:

C:\\Users\otLinusTorvalds\\AppData\\Local\\Packages>dir
 Volume in drive C has no label.
 Volume Serial Number is B621-8661

 Directory of C:\\Users\otLinusTorvalds\\AppData\\Local\\Packages

2019-05-09  00:28    <DIR>          .
2019-05-09  00:28    <DIR>          ..
2018-12-10  21:44    <DIR>          1527c705-839a-4832-9118-54d4Bd6a0c89_cw5n1h2txyewy
2019-04-08  17:16    <DIR>          46932SUSE.openSUSELeap15.0base_czpttgay3krvc
2018-12-10  21:45    <DIR>          46932SUSE.openSUSELeap15_022rs5jcyhyac
2018-12-10  21:45    <DIR>          46932SUSE.SUSELinuxEnterpriseServer15_022rs5jcyhyac
2018-12-10  21:39    <DIR>          ActiveSync
2018-12-10  21:45    <DIR>          c5e2524a-ea46-4f67-841f-6a9465d9d515_cw5n1h2txyewy
2018-12-10  21:45    <DIR>          DolbyLaboratories.DolbyAccess_rz1tebttyb220
2018-12-10  21:45    <DIR>          E2A4F912-2574-4A75-9BB0-0D023378592B_cw5n1h2txyewy
2018-12-10  21:45    <DIR>          F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE_cw5n1h2txyewy
2018-12-10  21:45    <DIR>          InputApp_cw5n1h2txyewy
2019-02-28  15:55    <DIR>          KaliLinux.54290C8133FEE_ey8k8hqnwqnmg
2018-12-10  21:45    <DIR>          Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy
...

…and when I CD into [FONT=Courier New]46932SUSE.openSUSELeap15.0base_czpttgay3krvc\LocalState\rootfs[/FONT], …here is what I see:

C:\\Users\otLinusTorvalds\\AppData\\Local\\Packages\\46932SUSE.openSUSELeap15.0base_czpttgay3krvc\\LocalState\\rootfs>dir
 Volume in drive C has no label.
 Volume Serial Number is B621-8661

 Directory of C:\\Users\otLinusTorvalds\\AppData\\Local\\Packages\\46932SUSE.openSUSELeap15.0base_czpttgay3krvc\\LocalState\\rootfs

2019-04-08  17:19    <DIR>          .
2019-04-08  17:19    <DIR>          ..
2019-04-08  17:19    <DIR>          bin
2019-04-08  17:16    <DIR>          boot
2019-04-08  17:19    <DIR>          dev
2019-04-08  17:27    <DIR>          etc
2019-04-08  17:25    <DIR>          home
2019-04-08  17:57           112,600 init
2019-04-08  17:16    <DIR>          lib
2019-04-08  17:27    <DIR>          lib64
2019-04-08  17:19    <DIR>          mnt
2019-04-08  17:16    <DIR>          opt
2019-04-08  17:16    <DIR>          proc
2019-04-08  17:16    <DIR>          root
2019-04-08  17:16    <DIR>          run
2019-04-08  17:27    <DIR>          sbin
2019-04-08  17:16    <DIR>          selinux
2019-04-08  17:16    <DIR>          srv
2019-04-08  17:16    <DIR>          sys
2019-04-08  17:27    <DIR>          tmp
2019-04-08  17:19    <DIR>          usr
2019-04-08  17:19    <DIR>          var
               1 File(s)        112,600 bytes
              21 Dir(s)  16,776,671,232 bytes free

I hope that helps :slight_smile:

…and just because you (or someone else reading this in the future) might ask, “…But how do I find [FONT=Courier New]C:\[/FONT] from WSL?”:

From WSL: cd /mnt/c (because Linux is easy like that)

ENJOY!