Moving files linux to windows

How to copy a file from Windows Subsystem for Linux to Windows drive C?

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:

Would you really want to put a user file into the C:\ root directory? Try copying to /mnt/c/Users/timgrindall .

@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.

5 Answers 5

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:

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!

Источник

How To Transfer File From Linux To Windows

transfer file from linux to windows

Copying files in Windows or Linux is simple enough. Copying files between them, though, not so much. The classic copy-paste with a USB stick method does work, but it’s not very efficient.

Instead, you can transfer files using protocols like SMB and SSH and using FTP applications such as FileZilla. We’ve listed step-by-step instructions for these and more methods in the sections below.

Ways to Transfer Files between Linux and Windows

Before you start, do keep in mind that, unlike Windows, Linux is case-sensitive. When entering the commands or file paths, users often forget this and can’t figure out why the file transfer doesn’t work despite following the steps correctly.

With that said, here are the various ways to transfer files between Linux and Windows.

Transfer Files Using SMB

The Server Message Block (SMB) protocol is a client-server communication protocol built into most Linux distributions. Here are the steps to transfer files using SMB:

  1. On your Windows system, locate the folder you’re trying to share.
  2. Right-click the folder and select Give access to > Specific People.
    give-access-to-specific-people
  3. Click on Share and press Done on the next screen.
    choose-people-to-share-with
  4. Next, press Win + R, type cmd , and press Enter.
  5. Type ipconfig and press Enter. Note the IPv4 address of the first adapter on the list.
    ipconfig ipv4 address
  6. On the Linux system, launch the File Browser and click on + Other Locations.
  7. In the Connect to Server field, enter the IP from Step 5 in the following format:
    smb://IP
    ubuntu-network-locations-smb-ip

Transfer Files Using SSH

Secure Shell Protocol (SSH) is a cryptographic network protocol commonly used for remote login. With an SSH client such as PuTTY, you can transfer files between Linux and Windows via the command line. Here are the steps to do so:

ip-addr

  1. On the Windows system, download and install PuTTY if you haven’t already.
  2. On the Linux system, press CTRL + Alt + T to launch the Terminal.
  3. Install and enable SSH with the following commands on Debian-based Linux systems such as Ubuntu:
    sudo apt install ssh
    sudo systemctl enable ssh —now
  4. On RedHat, CentOS, Fedora, and other systems, use these commands instead:
    sudo apt install OpenSSH
    sudo systemctl enable sshd —now
  5. In case you’re getting blocked by the firewall, use the following command:
    sudo ufw allow 22/tcp
  6. Enter ip addr and note the IP Address.

ssh-pscp-file-transfer-syntax

  • On the Windows system, open Command Prompt and use the commands listed below as appropriate.
  • The following command is to copy a single file. The example shows the file named doc.txt being copied from a remote Linux system to the D drive on the Windows system.
    pscp user@host:remote_path/file_name host_path\file_name
  • To copy all files in a folder:
    pscp user@host:remote_path/* host_path\
    eg: pscp anup@192.168.10.65:/home/anup/Desktop/naya/* D:\testfolder\
  • To copy all files & folders in a folder:
    pscp -r user@host:remote_path/ host_path\
    eg: pscp -r anup@192.168.10.65:/home/anup/Desktop/naya D:\testfolder\
  • Transfer Files Using SFTP

    You can also use a third-party tool such as FileZilla to transfer files using SFTP (SSH File Transfer Protocol). Here are the steps to do so:

    1. On the Linux system, follow Steps 1 – 6 from the section above to set up SSH.
    2. On the Windows system, launch FileZilla and select File > Site Manager > New Site.
    3. In the Protocol field, select SFTP – SSH File Transfer Protocol.
      filezilla-sftp-ssh
    4. In the Host field, enter the Linux IP Address from Step 6 of the section above.
    5. Fill in the login credentials of your Linux system and press Connect.
    6. If prompted, enable the Always trust this host option and press OK.
    7. Now that the connection is established, you can transfer files between Windows and Linux by dragging and dropping or right-clicking the file and selecting Upload/Download.
      upload-filezilla

    How to Transfer File from Linux to Windows VM?

    You can easily transfer files from Linux to a Windows VM using a USB Stick. Of course, that’s just one easy method. We have an article that details multiple ways to transfer the files for your further reading.

    Anup Thapa primarily covers Windows systems, networking, and computer hardware at TechNewsToday. Anup has been writing professionally for almost 5 years, and tinkering with PCs for much longer. His love for all things tech started when he got his first PC over 15 years ago. It was a Pentium IV system running Windows XP on a single 256 MB stick. He spent his formative years glued to this PC, troubleshooting any hardware or software problems he encountered by himself. Professionally, Anup has had brief forays into a variety of fields from coding and hardware installation to writing. In doing so, he’s worked with people of different backgrounds and skill levels, from average joes to industry leaders and experts. This has given him not just a versatile skill set, but also a unique perspective for writing that enables him to concisely communicate complex information and solve his reader’s problems efficiently. You can reach out to him at anup@technewstoday.com.

    Источник

    How to Copy Files from Linux to Windows

    You may have copied numerous files and directories from one location to another within a single operating system. Have you ever attempted copying a file from one operating system to another? If you have tried, you’ve most likely failed. This guide will demonstrate how to copy a file from one operating system to another. Within this article, we will be discussing a unique and straightforward method to transfer or make a duplicate of a file/folder from Linux to Windows or vice versa. So, you need to update your system first. For updation, try to use the “apt” package within the update instruction with sudo rights. Add your sudo account password, and the system will get updated in a few seconds.

    After a successful update, upgrade your system if it is required. Use the below-shown upgrade command using the “apt” package.

    Install SSH Server:

    Within some cases, we may require the ssh-server to transfer files between two different operating systems, i.e., Linux and windows. Therefore, we need first to install an ssh server on our Ubuntu 20.04 system. For installation, use the below-shown “apt” command.

    Tap “y” upon being asked to continue the installation of ssh-server on your system.

    To check whether the ssh service is currently active and enabled on our Linux operating system or not, you have to use the systemctl instruction in the shell. Use the word “status” at the last of this instruction. The output shows that the service is currently active on our system.

    Install Samba Tool:

    You must first ensure that the “samba” tool is installed on your machine before using any approach. If not, try using the apt installation command below with the name “samba.” Add your sudo account password, and the execution will be started.

    Tap “y” to continue installing and processing the “samba” package on our Ubuntu 20.04 Linux operating system.

    After its successful installation, you have to create a samba user, i.e., “test” using the usermod instruction. After that, add the smbpasswd command on the shell to create a password for this account. Add password on asked one after another as shown below.2

    From Windows to Linux:

    Before going up with the copy files between Linux and Windows systems, you need to find out the ip address of the Windows operating system. To find out the ip address, open your windows command prompt application and execute the “ipconfig” command on it. It will display the different WLAN settings of your windows system. The first adapter WLAN setting will show you your system’s “ip address.” Note it down for now.

    Now, within the windows “Local Disk©” directory, you have to create a new folder to be shared. As you can see from the image beneath, we have named “Share.” We need to update the privileges of this folder to allow remote users access. So, right-click on it and hover over the “Give access to” option. It will expand further, and you have to select the “Specific people..” option, as per the below-shown output image.

    The below screen “Network access” will be opened. As there is only one owner of this folder right now, you have to add a new user here.

    So, we have added the user “Everyone” and assigned it to read/write privileges for this folder. Tap on the “Share” button to continue applying the changes.

    Your folder is now shared, and anyone can access it. You can also see the file path shown in the below image. Tap on the “Done” button to exit.

    Open the file explorer within the Ubuntu 20.04 system and tap on the “Other locations.” You will check the “Connect to server” option at the bottom of the screen. At the text bar, write the simple URL command of the format shown below to get the shared file from the Windows system. Tap on the “Connect” button to do so.

    A dialogue shown below will appear. You have to add a registered user’s name, domain name, and password for the Ubuntu 20.04 system. Tap on the connect button after that.

    The folder “Share” from the windows system will be opened in your Ubuntu 20.04 system, as shown below. We have added a new text file from our Ubuntu system to this folder.

    On checking the Windows “Share” folder, we have got to know that the file from Ubuntu’s “Share” folder is also here, as demonstrated below.

    From Linux to Windows:

    To copy a file from Linux to windows, you have to create a new folder, i.e., “Share,” in the home directory, as shown below. Right-click on it and tap on “Properties.”

    Expand the ” Local Network Share ” section within the Properties dialogue that appeared on your screen, expand the “Local Network Share” section. Check to mark the “Share this Folder” option and the “Allow others to create and delete” option. Tap on the below “Share” button and close it.

    Now, your folder has a “share” sign on it.

    Open the “run” application in windows and run the IP address URL with a double backslash sign, i.e.,//ip-address. The “Share” folder will be opened on your Windows “Network” file explorer.

    Conclusion:

    This was all about transferring or copying a file from Linux to the Windows operating system. For more clearance, we have tried to copy the file from Windows to Linux first. We have used the Ubuntu 20.04 Linux operating system and Windows 10 to copy files. All steps elaborated in this article will be helpful for all types of users.

    About the author

    Omar Farooq

    Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.

    Источник

    Читайте также:  Linux snmp свой mib
    Оцените статью
    Adblock
    detector