24

I wrote a small program that calculates the Fibonacci sequence in the C programming language and wanted to move the fibo.c file to my regular C drive. I wrote it using Nano in Ubuntu running on the Windows Subsystem for Linux. When I try using the cp command to copy the file to /mnt/c which is where my C drive is, I get the error:

"cp: cannot create regular file 'mnt/c/fibo.c': Permission denied"

Does anyone know how to circumvent this?

Note: I also tried using sudo cp as well.

4
  • 1
    Would you really want to put a user file into the C:\ root directory? Try copying to /mnt/c/Users/timgrindall. May 19, 2018 at 0:50
  • Extremely relevant: superuser.com/questions/1114341/…
    – Ramhound
    May 19, 2018 at 0:52
  • G-Man: Good point. I tried moving it into my user directory and that worked fine. May 19, 2018 at 0:55
  • @timgrindall, If your question answered sufficiently? If so, please mark one of the given answers to close this question. Your gesture will be helpful for others to get the right solution to this problem. Feb 7 at 3:16

5 Answers 5

33

Does seem like an older issue, but might prove useful for others: I find the easiest way to achieve file copies from WSL to windows without having to struggle with permissions is as follows:

1) Open "File explorer"

2) Connect to your running WSL instance just like you would connect to a network drive: --> Enter \\wsl$\< WSL_Distro > in the address bar

3) Browse your WSL folder structure ;)

enter image description here

From here you can copy your Linux files, and paste them on your windows folders. Do note that I do not recommend that you copy file from windows to WSL using this method.

If you want to copy to WSL, Best use the "/mnt/" method!

3
  • This answer really should be modified to make it clear, the instructions indicated, do not work for older versions of Windows 10.
    – Ramhound
    Jun 2, 2020 at 13:17
  • @YunfeiChen - If it worked then you are running a supported version of Windows 10. What was in dispute is this doesn’t work on earlier versions of Windows 10
    – Ramhound
    Jul 2, 2021 at 22:01
  • 2
    @Ramhound pretty sure earlier versions of windows 10 forces you to update anyways so it should be an non issue.... Jul 3, 2021 at 0:54
6

The Widnows is mounted at this location

/mnt/c/Users/[Username]/..

Just copy the files to this location.

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 15, 2021 at 12:26
  • Additionally you can see other drives at /mnt/d etc, would be really easy to just use cp
    – 27px
    Oct 6 at 9:11
3

Maybe this will work for you:

  1. Copy the file you want to share
  2. Open ubuntu bash
  3. Type explorer.exe . in ubuntu bash
  4. Paste the files
0

You do not have permissions to move the file:

Check the permissions by doing:

ls -l

If the above says root this means that the superuser sudo has the access.

You can elevate your permissions by prefixing sudo before your command

sudo cp ~/fibo.c /mnt/c/fibo.c'
0

check permission: ls -l

make it read and write for other users: sudo chmod 666 <file_name>

copy from WSL Linux and paste to windows any other folder

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .