Copy Files from Windows to Windows Subsystem for Linux (WSL)
Solution 1
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
Hope this helps!
Solution 2
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/
JordanGS
Updated on April 29, 2021Comments
-
JordanGS about 3 years
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 beon 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 inC:\Users\<windows.username>\AppData\Local\lxss\home\<ubuntu.username>\Pictures
, even if i restart bash or windows, the file is not visible when i dols -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. -
JordanGS about 7 yearsI 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.
-
zoecarver about 7 yearsyou are probably in the wrong folder.
-
Harry Johnston about 7 yearsThe Linux subsystem doesn't have the same design criteria as Cygwin. You can't necessarily expect them to behave similarly.
-
Harry Johnston about 7 yearsSee also WSL File System Support.
-
Chris Buck over 5 yearsIn 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.
-
user2804070 over 5 yearsit worked for me, though
ubuntu.username
is not necessary the username for windows.. al least it is not the case for me ;) -
Gubatron over 5 yearsLove you for this.
-
Janac Meena about 5 years@JordanGS it may be a permissions issue
-
Ambroise Rabier over 4 yearsOn 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.
-
reker over 4 years@AmbroiseRabier In latest version of WSL, use SFTP, tar file, or integrated 9p protocol.