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
- Copy folder to
C:\Users\<username>\AppData\Local\lxss\home\
with Windows Explorer - Check home directory with Bash on Ubuntu on Windows (bash)
ls -a
- Observe that the folder does not exist
- Repeat steps 1-3 with a regular text file
- Create folder within bash
mkdir TestFolder
- Check
C:\Users\<username>\AppData\Local\lxss\home\
with Windows Explorer - Observe that the folder exists
- Repeat steps 5-7 for a regular file
touch somefile.txt
- Open
somefile.txt
with your favorite text editor and make some changes - 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".
Best Answer
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):
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:
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.