185

I have enabled developer mode and installed Bash on Ubuntu on Windows.

My home directory can be found under %localappdata%\Lxss\home\<ubuntu.username>\, i have created a sub-directory called Pictures such that the full path should be

on windows: C:\Users\<windows.username>\AppData\Local\lxss\home\<ubuntu.username>\Pictures

on bash: /home/<ubuntu.username>/Pictures

if i create a file from bash using the command touch hello.txt i can freely see this file in the windows UI and copy it to my Desktop. However, if i create a new text file from the windows UI and save it in C:\Users\<windows.username>\AppData\Local\lxss\home\<ubuntu.username>\Pictures, even if i restart bash or windows, the file is not visible when i do ls -l.

Why can't bash see files created from the Windows side in it's own home directory?

EDIT Using /mnt/c is not a solution, i am trying to understand why it doesn't see those files and if there is a remedy to that so that it will be able to see UI created files, rather than trying to use the terminal to copy-paste or move files over.

Nico Nekoru
  • 2,840
  • 2
  • 17
  • 38
JordanGS
  • 3,966
  • 5
  • 16
  • 21
  • 2
    Interesting! My guess - and it *is* just a guess - is that the Linux subsystem keeps track of its own files and never looks to see if any others have been added. That would sort of make sense, because otherwise it would be difficult to give the virtual file system UNIX semantics for things like deleting files and case sensitivity. I suspect you'll find that if you create `hello.txt` and `HELLO.TXT` from Bash, one of the files will be under a different name when you look at it in Windows. – Harry Johnston Mar 03 '17 at 23:04
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. Also see [Where do I post questions about Dev Ops?](http://meta.stackexchange.com/q/134306) – jww Mar 05 '17 at 01:27
  • As @HarryJohnston supposed, the names are different. Both long and short. But only in the case, even short ones (!) – Serhii Kheilyk Jun 07 '17 at 01:21
  • I'm voting to close this question as off-topic because it is related to the ask-ubuntu community. – OmG Feb 23 '18 at 17:53
  • 1
    @OmG Many questions do not belong strictly on one site. However, this is better suited to [su], since two different OSes are involved. (Or, strictly speaking, only Windows is involved.) – jpaugh Feb 23 '18 at 18:27
  • 2
    @jpaugh I know. But, this question is justified to ask-Ubuntu circumstances and not off-topic. – OmG Feb 23 '18 at 18:38
  • 1
    I find the question pertinent and here is the answer: https://ridicurious.com/2018/10/18/2-ways-to-copy-files-from-windows-10-to-windows-sub-system-for-linux/ – Francesco Mantovani Oct 23 '18 at 08:38
  • A question about development environments should be on-topic. Which SO rule do I need to address? – Lee Goddard May 02 '22 at 07:26
  • @LeeGoddard WSL is not just for development though. Following your reasoning, because I develop on Windows and MacOS, all Windows and MacOS questions would be on-topic as well. They are not. – Mark Rotteveel May 12 '22 at 10:43
  • @MarkRotteveel I don't see how that addresses my question. – Lee Goddard May 12 '22 at 14:11
  • 1
    @LeeGoddard This question is not development related, but simply an OS question, and as such is not about tools primarily used for development, and thus is off-topic (point 6 on https://stackoverflow.com/help/on-topic). – Mark Rotteveel May 12 '22 at 16:17
  • 1
    Given the amount of reach and help this question has given members of the community, regardless of what rules you point this... Wasn't that the intent of stackoverflow to begin with? To help others and to help each other learn programming, operating systems, etc.. You guys can do w/e you want, I'm just glad that my question was able to help quite a few people who were struggling with the same issue as I. All the best o/ – JordanGS May 19 '22 at 02:05
  • Those who have read the question and find themselves in these circumstances understand that this is a question regarding Windows and using the Windows Subsystem for Linux (WSL) tool that is available in that OS. WSL is available for development purposes more than running Linux stuff on Windows. – Bobort Jan 24 '23 at 17:54

2 Answers2

333

You should be able to access your windows system under the /mnt directory. For example inside of bash, use this to get to your pictures directory:

cd /mnt/c/Users/<windows.username>/Pictures
starball
  • 20,030
  • 7
  • 43
  • 238
zoecarver
  • 5,523
  • 2
  • 26
  • 56
  • I believe you misunderstood. I have a JPG on my desktop, i copied it with the UI into the bash subsystem directory. I am trying to understand why bash can't see those pictures when they are in it's home directory. This is basic cygwin behavior, drag and drop or copy paste files over without relying on linux commands to do the job. – JordanGS Mar 03 '17 at 19:31
  • you are probably in the wrong folder. – zoecarver Mar 03 '17 at 22:27
  • The Linux subsystem doesn't have the same design criteria as Cygwin. You can't necessarily expect them to behave similarly. – Harry Johnston Mar 03 '17 at 23:06
  • it worked for me, though `ubuntu.username` is not necessary the username for windows.. al least it is not the case for me ;) – Taktech Oct 18 '18 at 09:22
  • @JordanGS it may be a permissions issue – Janac Meena Mar 16 '19 at 20:25
72

You should only access Linux files system (those located in lxss folder) from inside WSL; DO NOT create/modify any files in lxss folder in Windows - it's dangerous and WSL will not see these files.

Files can be shared between WSL and Windows, though; put the file outside of lxss folder. You can access them via drvFS (/mnt) such as /mnt/c/Users/yourusername/files within WSL. These files stay synced between WSL and Windows.

For details and why, see: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

Kai Ninomiya
  • 156
  • 2
  • 6
reker
  • 2,063
  • 13
  • 12
  • See also [WSL File System Support](https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/). – Harry Johnston Apr 15 '17 at 01:46
  • 1
    In [WSL File System Support](https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/) it describes why the behavior is happening: the file "translation" is done in the lsxx subsystem (on the linux side) only. – Chris Buck Sep 20 '18 at 08:48
  • 1
    On a linux VM, I can use SFTP to transfer files, what do I use to transfer file PROPERLY from Window to linux subsystem ? this does not provide a solution. – Ambroise Rabier Oct 19 '19 at 11:05
  • 1
    @AmbroiseRabier In latest version of WSL, use SFTP, tar file, or integrated 9p protocol. – reker Oct 21 '19 at 01:24