Accessing Ubuntu data (like "/etc") from Windows

2

1

I'm using Ubuntu from the Windows Store.

When I use a terminal command like "find", I see that it also lists files from my Windows drive.

So Ubuntu can access the Windows file system which is great.

Now I would like to do the opposite: I would like to have a look at the files and folder of the Ubuntu system from Windows.

For example, I would like to have a look at the "etc" folder from Explorer.

Is that possible?

tmighty

Posted 2018-05-21T12:49:49.153

Reputation: 119

1

You might want to have a look at this question -- https://superuser.com/q/1110974/302907

– Anaksunaman – 2018-05-21T12:56:38.913

@Biswapriyo Not OP, but if you can provide a good answer, I would say go for it. =) – Anaksunaman – 2018-05-21T15:43:57.237

@Biswapriyo Yes, please! – tmighty – 2018-05-21T17:14:58.670

Possible duplicate of Where is the Linux Subsystem's filesystem located in Windows 10?

– Jaime – 2018-07-29T05:08:32.933

Answers

2

  • Disclaimer: The following procedure has made with over simplification so that normal user can understand. The mentioned articles are for enthusiasts. Other may skip those.

Normal Windows executables (Win32) preferably stores user configuration/log files in %LocalAppData% folder that is C:\Users\%USERNAME%\AppData\Local. But in Windows Universal Platform (UWP), that path is redirected to another which is C:\Users\%USERNAME%\AppData\Local\Packages\package_name. The package_name is specific for concerned UWP package. With this type of path redirection, the user configuration/log files are automatically deleted at time of uninstallation. Follow this article for further details.

Here are the path structures:

  • Installation Folder:

    • Normal app: C:\Program Files\
    • UWP app: C:\Program Files\WindowsApps\<Publisher Name>.<App Name>_<Version Code>_<Random String>
  • Local AppData Folder:

    • Normal app: C:\Users\<User Name>\AppData
    • UWP app: C:\Users\<User Name>\AppData\Local\Packages\<Publisher Name>.<App Name>_<Random String>

Now compare the following example with the above path structures. Ubuntu 18.04 from Windows Store installs in:

C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.427.0_x64__79rhkp1fndgsc

And the redirected Local AppData will be:

C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState

I've made a PowerShell script with which one can open that Linux rootfs (i.e. /) folder in File explorer. This uses Get-AppxPackage cmdlet to get the Appx package name. Copy the following lines into Notepad and save it with .ps1 extension (instead of .txt). Then run it in PowerShell.

$DistroName=Read-Host "Enter Distribution Name"
$pacakgeName = (Get-AppxPackage *$DistroName*).PackageFamilyName
$appData = [System.Environment]::ExpandEnvironmentVariables("%LocalAppData%")
$rootfs = $appData + "\Packages\" + $pacakgeName + "\LocalState\rootfs"
echo $rootfs
Invoke-Item $rootfs
Read-Host -Prompt "Press any key to continue..."

Biswapriyo

Posted 2018-05-21T12:49:49.153

Reputation: 6 640

Thank you. The sentence "And the redirected Local AppData will be" already told me what I wanted to know. Thank you. – tmighty – 2018-05-22T20:03:37.017