4

Using Bash on Ubuntu on Windows 10 I know that my home folder is located at C:\Users\<username>\AppData\Local\lxss\home\ and all other stuff is somewhere there too.

When I copy things to ...\lxss\home with Windows Explorer it doesn't show up in bash. Maybe file systems, maybe permissions? Alright, let me just copy stuff from \mnt\c\... then via bash. Works.

Now I just want to edit a file weirdfile.txt in my home directory. I open it up with Windows Notepad, edit it, save it - it's gone from bash. Physically I can still see it hanging around in the folder with Windows Explorer, but in bash it is gone. Not hidden. sudo doesn't help. Starting bash as admin doesn't help.

Steps to reproduce

  1. Copy folder to C:\Users\<username>\AppData\Local\lxss\home\ with Windows Explorer
  2. Check home directory with Bash on Ubuntu on Windows (bash) ls -a
  3. Observe that the folder does not exist
  4. Repeat steps 1-3 with a regular text file
  5. Create folder within bash mkdir TestFolder
  6. Check C:\Users\<username>\AppData\Local\lxss\home\ with Windows Explorer
  7. Observe that the folder exists
  8. Repeat steps 5-7 for a regular file touch somefile.txt
  9. Open somefile.txt with your favorite text editor and make some changes
  10. Observe that somefile.txt is gone (ls -a) when looked at in bash.

What is going on here? Shed some light on the virtualized file system and tell me how to work with files from within Windows. SSH into localhost and edit files via SCP? No, thank you. Can I just work with files with the Explorer / Windows tools, please?

I can do you one better:

ln -s /mnt/c/Users/<username>/Desktop/weirdfile.txt /~/weirdfile.txt

Works. Never disappears. I can work with the file with Windows tools. The world is a better place. Unfortunately Bash on Windows doesn't seem to understand Windows symlinks/hardlinks, so I have to symlink everything from within bash.

PS: It feels weird tagging a question with "ubuntu" and with "windows".

migrated from unix.stackexchange.com Sep 20 '16 at 16:17

This question came from our site for users of Linux, FreeBSD and other Un*x-like operating systems.

  • 1
    Check out this blog post published by the Bash on Windows team at Microsoft. It addresses most if not all of your questions. WSL File System Support – jackchammons Sep 23 '16 at 0:04
  • It's you, Jack Hammons. Great community outreach! Yes, the official resource almost explains everything. It does not explain whether I should use linuy symlinks ln -s to have interoperability with files in Linux as well as in Windows. I have several files now I work with in my Windows My Documents and symlinked these into my WSL home folder. Works like a charm I can work on the files with both systems. Am I creating a mess? – Dennis G Sep 23 '16 at 13:02
4

So Jack Hammons, a program manager from Microsoft linked to this great official resource: https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/

Problem is that I'm pretty much out of luck (a little edited from link above):

While [WSL] files are stored in regular files on Windows in the directories mentioned above, interoperability with Windows is not supported. If a new file is added to one of these directories from Windows [WSL] simply ignores it. Many editors will also strip the [Extended Attributes, which are used for storing WSL metadata] when saving an existing file, again making the file unusable in WSL.

Additionally, since [WSL] caches directory entries, any modifications to those directories that are made from Windows while WSL is running may not be accurately reflected.

So it seems even though I can see the files/folders in C:\Users\<username>\AppData\Local\lxss\home\, I should not interact with them with Windows.

On Symbolic links:

While NT supports symbolic links, we could not rely on this support because symbolic links created by WSL may point to paths like /proc which have no meaning in Windows.

One question remains: When symlinking files from somewhere on /mnt/c/ everything seems to work fine from Windows as well as from WSL. So right now I have several folders symlinked from My Documents into my WSL home folder. Am I messing things up?

EDIT: Rich Turner was so kind to put this information in a semi-official blog post here https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/. Although not specified my symlinking idea actually seems to be a good way as the mounted NTFS partitions are treated differently.

  • 1
    I wrote-up additional information and background on this subject here: blogs.msdn.microsoft.com/commandline/2016/11/17/… Please point people at this guidance if ever you see it being mentioned in tweets\posts etc. – Rich Turner Nov 17 '16 at 18:55
  • Hah, I was just going to link to this post from your article - came here to grab the link. Apparently you were aware. Love it! – Dennis G Nov 18 '16 at 6:13
  • 1
    LOL :) Yeah, I received this question ~4 times on the same morning so decided to write this up once and for all ;) – Rich Turner Nov 18 '16 at 18:59
  • the issue with ln -s... is that the linux files still will not reflect changes made to the windows files. at the very least i am encountering this issue and can't find any info about this anywhere and nobody seems to want to help – user2230470 Aug 12 '17 at 0:25
  • 1
    @Anthony - we're always happy to help where we can. You can always ping me at twitter.com/richturn_ms and/or file an issue on our GitHub here: github.com/microsoft/bashonwindows. – Rich Turner Sep 7 '17 at 19:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.