Score:7

Where is WSL located on my computer?

ma flag

I am new to Windows and have installed WSL2 based on the instructions provided here.

It works fine, but I cannot locate where it has been installed on my computer. The output for pwd is home/nkp68.

How do I access files in my Windows machine from WSL2?

ag flag
Look under `/mnt/c/Users/`
muru avatar
us flag
Does this answer your question? [Where is the Ubuntu file system root directory in Windows Subsystem for Linux and vice versa?](https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-subsystem-for-linux-an)
Krutik avatar
ma flag
The answers posted in the question you posted @muru are very helpful but the answer given by NotTheDr01ds was not present there. I think this answer is extremely good and may help other people so keeping this post active would be best.
muru avatar
us flag
If anything, this post should be merged with that one, since the question(s) are pretty much the same.
Krutik avatar
ma flag
I think that is reasonable. I am not sure how to do this though. - Should I comment in the other post adding a link to this post?
Score:18
vn flag

If I read your post literally, there may be a few different questions there:

  • Where is your WSL Ubuntu instance installed on your machine?
  • (Presumably based on the first question) How do I access files in WSL2 from Windows?
  • "How do I access files in my Windows machine from WSL2?" (sort of the opposite question of the first two)

Where is your WSL Ubuntu instance?

Short answer: In your case, given the basic installation, the actual files are in a virtual disk named ext4.vhdx. You really don't need to worry about the "where" at this point (since it's a virtual drive), but you'll typically find it under %userprofile%\AppData\Local\Packages\Canonical...\LocalState\ext4.vhdx. Your %userprofile% is typically something like C:\Users\<username>.

More Detail:

That's for a default installation. You can have multiple distributions installed, and even multiple instances of the same distribution. One of the great things about WSL is the ability to quickly copy a distribution, test something out, and throw away the test. This keeps you from polluting your "good", daily distribution with packages, tests, or other things that may create "cruft" over the long-term.

To see all the distributions you have installed, go to PowerShell and run:

Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse

In your case, you'll probably see something like:

{cff9bfd6-39db-42af-a85b-d6fca State              : 1
94beff8}                       DistributionName   : Ubuntu
                               Version            : 2
                               BasePath           : C:\Users\krutik\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState
                               Flags              : 15
                               DefaultUid         : 1000
                               PackageFamilyName  : CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
                               KernelCommandLine  : BOOT_IMAGE=/kernel init=/init
                               DefaultEnvironment : {HOSTTYPE=x86_64, LANG=en_US.UTF-8, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games, TERM=xterm-256color}

I have quite a few more, in various locations.

How do I access files in WSL2 from Windows?

But the title of your question, "where", doesn't really matter much unless you need to do something with the ext4.vhdx file (like perhaps reclaim space).

To access files in WSL from Windows, use the \\wsl$\Ubuntu path (or whatever your distribution is named). Here, you'll find \\wsl$\Ubuntu\home\nkp68, where you can safely copy in and out files.

How do I access files in my Windows machine from WSL2?

If you are in Ubuntu and need access to a file on a Windows drive (e.g. C:), then you'll find those are (by default) auto-mounted for you:

ls /mnt/c/Users
ls /mnt/c

There are some nuances in working with files on a Windows drive from within WSL, especially around permissions and performance. You'll typically want to keep any project files inside the Ubuntu ext4 filesystem (e.g. under your /home/nkp68 directory). But you can certainly access, copy, and move files around between the drives as needed.

Hagen von Eitzen avatar
fr flag
To add to the last part of this answer: How to access network drives (e.g. mapped by `NET USE F: \\server\share`) from WSL? Do something like `sudo mount -t drvfs F: /mnt/f/` (after first creating directory `/mnt/f`, or use a different directory as mount point - not recommended)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.