Score:1

Accessing Ubuntu WSL files from Kali WSL and vice versa

gb flag

I have 2 wsl distros running on my pc, Ubuntu and Kali Linux. I have some programs installed and some files on my kali linux system that I want to access or edit through the Ubuntu distro. How can I do it? Are the files located somewhere in the file system that I can access through Ubuntu?

Thank You! Any help is appreciated.

Zeiss Ikon avatar
cn flag
WSL controls where guest OS files are stored, and WSL is outside our support, AFAIK. However, welcome to AskUnbuntu! Please take the [tour] and read the [FAQ] to understand what we can and can't answer here.
NotTheDr01ds avatar
vn flag
Hi @ZeissIkon - Just a heads-up that WSL is on topic here as long as it relates to Ubuntu. See [this Meta answer](https://meta.askubuntu.com/a/17935/1165986) from Zanna (mod) for confirmation. Ubuntu on WSL *is* an official Canonical release, so it falls into our "on-topic" guidance. Thanks!
Zeiss Ikon avatar
cn flag
@NotTheDr01ds The core of the question, however, is where WSL stores the files for Kali, which is not supported -- right?
NotTheDr01ds avatar
vn flag
@ZeissIkon Not really - Read that meta answer closely, the last line is *"We should not close questions just because they smell Minty/Windowsy."* Also, the quote from another answer, *"unfortunately people often ask themselves "Is this (also) about something that isn't Ubuntu?" instead. That's the wrong question to ask."*
Zeiss Ikon avatar
cn flag
@NotTheDr01ds Okay. I give up. I can't read every meta post, so apparently I shouldn't have the ability to cast close votes, since what should and shouldn't be closed as unsupported has dozens of inconsistent (IMO) edge cases. Even referring new users to the tour and FAQ won't help, because they don't cover all those edge cases.
NotTheDr01ds avatar
vn flag
@ZeissIkon No worries - You did qualify your comment with "AFAIK", which is better than a lot of folks have done :-). And no, we can't all read every Meta post. But that's why we still require 5 close votes for it to take effect. Those that are truly off-topic do get closed quickly, but those that are corner cases usually get "caught" before enough close votes are cast. And if it comes to it, the Mods are really good about re-opening questions that were wrongly closed here.
Score:2
vn flag

It's a bit odd:

Accessing WSL files from Windows is easy and built-in to WSL -- Just use the \\wsl$\<distro> drive share.

Accessing Windows files from WSL is also easy -- Just use the /mnt/<drive_letter> mount points.

Accessing files in one WSL instance from another isn't "built in", but can be accomplished through the use of bind mounts in each distro to the shared /mnt/wsl tmpfs mount.

Just execute the following command in both Ubuntu and Kali:

sudo sh -c "echo \"/ /mnt/wsl/instances/$WSL_DISTRO_NAME none defaults,bind,X-mount.mkdir 0 0\" >> /etc/fstab"

Then exit each, issue a wsl --shutdown from PowerShell or CMD (a --terminate of each would suffice as well), and restart.

You'll find the files for each now in their respective /mnt/wsl/instances/<distroname> bind mount.

This works by creating an /etc/fstab entry that creates a bind mount using the distribution name in /mnt/wsl/instances/$WSL_DISTRO_NAME when the instance is started. the X-mount.mkdir allows mount to create the parent directories needed if they don't exist, similar to mkdir -p.

The /mnt/wsl directory is a tmpfs that is automatically:

  • Created by WSL when it first starts

  • Available to all WSL2 distributions

  • Note that this does not work for WSL1 distributions

  • Also note that this method requires both distributions to be running. For some methods that don't require the second distro to be running, see my older methods in this Super User answer. Options 2 and 3 will both work even if the second distro isn't running.

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.