Accessing Ubuntu data (like "/etc") from Windows
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?
Solution 1:
- 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>
- Normal app:
-
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>
- Normal app:
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..."