17

I've installed the Windows 10 Anniversary Update on my computer.

I would like to know where the /root directory in Bash prompt is within Windows?

I would like to be able to write files in Bash that are accessible from Windows too

i.e.- If I do:

touch /root/foo

Where do I go to access foo in My PC

magicandre1981
  • 97,301
  • 30
  • 179
  • 245
Patrick
  • 1,246
  • 2
  • 14
  • 21
  • Did you Google first? – phuclv Aug 06 '16 at 08:52
  • @LưuVĩnhPhúc yes, and all I could find were articles about where the C drive is located inside the Bash script, but nothing the other way around – Patrick Aug 06 '16 at 20:09
  • really? I copied your question into Google and [this](http://askubuntu.com/q/759880/253474) appears on top – phuclv Aug 07 '16 at 14:26
  • Possible duplicate of [How to access linux/Ubuntu files from Windows 10 WSL?](https://superuser.com/questions/1110974/how-to-access-linux-ubuntu-files-from-windows-10-wsl) – Bob Aug 28 '19 at 04:59
  • (I am suggesting to close as dupe in reverse-chronological order as the other question is both more general and has far better and more up-to-date answers.) – Bob Aug 28 '19 at 05:00

4 Answers4

11

I believe this link will answer your question:

https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-nt-subsystem-and-vice

In short:

%localappdata%\Lxss\rootfs

or

C:\Users\Username\AppData\Local\Lxss\rootfs

kruschk
  • 320
  • 1
  • 11
1

The folder changed again:

%localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs

C:\Users\{Username}\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
Ernst Robert
  • 111
  • 4
  • Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by [voting to close it as a duplicate](https://superuser.com/help/privileges/close-questions) or, if you don't have enough reputation for that, [raise a flag](https://superuser.com/help/privileges/flag-posts) to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places. – DavidPostill Sep 15 '17 at 06:13
1

In my case, running last windows update (creators fall) with ubuntu upgraded, the files are still in C:\Users\Username\AppData\Local\lxss\ but the lxss directory became "invisible". However, just editing the path at the top of the windows explorer manually make it work

1

Accessing the WSL file-system from within Windows is not supported. As soon as you do anything more than just reading those files from within the Windows environment, things will go wrong.


But the following part of the question is not impossible and easily supported, so I'll answer this:

I would like to be able to write files in Bash that are accessible from Windows too

You can't (should not) access the Linux filesystem from within Windows, but you can quite easily access the Windows file-system from within WSL. You will find all your fixed lettered Windows NTFS drives mounted under /mnt/*, so your "C-Drive" is mounted on /mnt/c, and so on.

For example your Windows home user path will be something like /mnt/c/Users/<usernamehere>

Mounting removable drives

You can mount some filesystems yourself: MSDN Blog

sudo mkdir /mnt/sdcard
sudo mount -t drvfs U: /mnt/sdcard

Note that the actual filesystem is in this case was exFAT, so you just use drvfs as long as Windows can read the actual file system.

More info

dualed
  • 591
  • 1
  • 5
  • 11