WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Copying files from windows to bash

Open ibr123 opened this issue 9 years ago • 14 comments

Hi everyone, im using Bash on windows 10, what i need to copy a folder from windows to the path inside the bash: "C:\Users<User>\AppData\Local\lxss\home..." i already tried that but once i start the bash and went to the location that i have copied the folder to and its not visible, and i tried ls -a and same result

Thanks

ibr123 avatar Apr 12 '17 14:04 ibr123

I'm not sure copying files there will work. Have you tried copying them to %APPDATA%\Local\lxss\rootfs\home... ?

daiconrad avatar Apr 12 '17 15:04 daiconrad

same problem +1

davidwudv avatar Apr 12 '17 15:04 davidwudv

What're you doing mucking around inside a hidden system directory? Don't do that :-) It's hidden for a reason (many settings dirs are not hidden), and that reason is that it's not user-editable and changing files in that location will typically corrupt your WSL installation.

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

Windows cannot access Linux-specific paths in WSL. Instead, WSL can access Windows-specific paths. So the way you do this is to open up a bash shell and do:

$ mv /mnt/c/path/to/your/files ~

(or whatever other paths you want to work with.)

Alternatively, it may make more sense to just point your Linux tools directly at your files in /mnt/c.

aseering avatar Apr 12 '17 15:04 aseering

see, the reason why i want to do such a strange thing like copying files from windows to Linux, because sometimes its much more easier that the official way, my background is Microsoft technologies, .Net, VS, Windows OS...etc. but i got a task that i have to deal with open source and its a small one, SUPPOSEDLY. it was only to install the tesserocr engine, but believe it or not that took me more than couple of days :( although i followed the instruction on the net, the last step was to use something called "git pull ..." to get some resources from the internet and didn't work at all, so i though as a work around to install it manually from the site and just copy it and place it there, and i wasn't surprised when that didn't work....but eventually worked, and by eventually i mean after posting many question here and there for an answer. so at the end, with a small step like that i didn't want to become a professional in Linux and just get it over with .....if you use Microsoft technologies and not a fan of open source, you would understand ;)

ibr123 avatar Apr 13 '17 07:04 ibr123

@ibr123 -- so, I totally do understand why you would want to use official Windows tools to edit files in Linux. That would be a very valuable feature; I would also love to see that exist, as would many others according to existing tickets.

(And yes, the open-source world can be quite a mess, and even the better projects/environments can have a big learning curve. Microsoft's curated APIs have a lot of value in a lot of situations.)

All I don't understand is why fellow Windows users might be confused that a particularly-locked-down private app-data directory might not work as expected :-)

aseering avatar Apr 13 '17 14:04 aseering

well, to be honest its the first time that i use bash on windows, one month ago i didn't even know that it comes with windows 10, so i didn't know that some directories are locked, but anyways that is the biggest problem, because the installation finally worked but now i have to deal with the engine itself :( and i know it would be a total mess. surprisingly although this engine is Linux based, its installation was much easier on windows than Ubuntu!!

ibr123 avatar Apr 16 '17 06:04 ibr123

Same problem, thank you~

Trumeet avatar Jun 11 '17 12:06 Trumeet

Same problem here.

thomasbeckford avatar Jul 24 '17 19:07 thomasbeckford

This doesn't solve the problem where, say, a linux program expects a config file under its hidden directory within home, and you need to create this config file and then place it there. How would I go about doing that?

mmortal03 avatar Apr 23 '18 22:04 mmortal03

Creating the file from a linux program should work, so you could use the wsl command to run a linux command like cp to copy the file from Windows into the Linux subsystem. For example:

  1. Create a file (say, "foorc") in a staging location such as: C:\stage\foorc
  2. Use wsl to copy it to the default user's home directory: wsl cp /mnt/c/stage/foorc ~/.foorc

You can delete the staging file afterwards if you like. For more information, see:

https://docs.microsoft.com/en-us/windows/wsl/interop

daiconrad avatar Apr 27 '18 04:04 daiconrad

Thanks, @daiconrad. I actually thought to try that a day after I posted this, but still couldn't get it to work. With fresh eyes today, I realized I'd simply typed the wrong name for the config file! I can confirm that your suggestion works.

mmortal03 avatar Apr 27 '18 08:04 mmortal03

@aseering - I can completely see "fellow Windows users might be confused that a particularly-locked-down private app-data directory might not work as expected": your fellow Windows users had no idea that the private app-data directory was "particularly-locked-down". I typed "Explorer.exe ." from my home directory and voila! - there I was in that locked-down directory! That was the entire point of this WSL integration exercise was it not?

OS X and the Linux UI itself set a very high bar in terms of expectations of UI-command-line integration. WSL is a great start but is clearly a ways off from my expectations. I hope that the team continues to improve upon it.

zielot avatar May 29 '18 15:05 zielot

@zielot Interop between Linux and Windows has greatly improved by leaps and bounds since this issue was first posted. No you can't straight move files or directly edit from Windows created in Linux but software tools such as VS Code are increasing compatiblity in this arena so that you can use both Windows and Linux tools to modify Linux files. As someone who had to treat Windows and Linux as separate beasts, WSL has greatly harmonized the two far more than what would of been expected a few years ago. WSL still has a long ways to go but it's quite usable as it is now. As far as "UI-command-line integration", you'll want to refer to https://github.com/Microsoft/Console as conhost is responsible for rendering the terminal for CMD/Powershell/WSL and has greatly improved interop in Skip-Ahead builds.

WSLUser avatar May 29 '18 15:05 WSLUser

@DarthSpock - I agree; WSL is a far cry from the POSIX compatibility layer and an entirely different world from the cmd console. I will for sure check out the ColorTool on the Console GitHub account.

zielot avatar May 30 '18 13:05 zielot