Copy Files Between Windows and Linux Using Command Line

Copy files from windows to linux

In this updated guide, I will walk you through the steps to copy files from Windows to Linux using easy-to-follow steps.

I will show you two ways to copy files from windows to Linux

  1. Using command line with pscp
  2. Using GUI FTP utility.

Copy File from Windows To Linux Using PSCP

It is not always that you will need to copy a file from Windows to Linux or vice versa.

But at times when you are automating things or trying to achieve some copy functionality using a script, it is good to have a utility to do that.

Here is where pscp comes into play. Using pscp you can copy the file to/from windows and Linux.

Step 1: Download pscp.exe from here. Select the appropriate package.

Download pscp to copy files from windows to Linux

Step 2: copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:\Windows\System32 path.

C folder location to save pscp.exe file

Step 3: Open Windows PowerShell and use the following command to verify if pscp is accessible from the path.

pscp

You should see the following output.

image 4

Step 4: Use the following format to copy the single file from Windows to the Linux box.

pscp -pw password C:\Users\Admin\Desktop\test.txt  \
[email protected]:/home/vagrant

Here is the explanation of the command.

  1. -pw for the password.
  2. Replace password with the Linux user password.
  3. C:\Users\Admin\Desktop\test.txt represents the path of the file that has to be copied to the Linux system.
  4. 192.168.33.10 is the IP of the Linux server.
  5. /home/vagrant is the user-accessible path in the Linux system to copy the file.

If you want to copy all the files in a directory to Linux, you need to add a start to the folder. eg. folder\*. An example is shown below.

pscp -pw password C:\Users\Admin\Desktop\folder\*  \
[email protected]:/home/vagrant

If you are using Linux private keys for authentication, you can use -i flag instead of -pw followed by the path to the .ppk , .pem or id_rsa file.

If your key file is in pem format, you can use the puttygen command to convert it to ppk. See this ec2 server guide for the pem to ppk conversion.

Info: Learn Linux & Windows administration from Pluralsight with its 10 days free account

For Linux Private key-based authentication, the command looks like below.

pscp -i /path/to/key.ppk C:\Users\Admin\Desktop\test.txt \
[email protected]:/home/vagrant

Copy File From Linux To Windows Using PSCP

You can use pscp to copy files from Linux to windows. use the following command format for the same.

pscp -pw password [email protected]:/path/to/file \
C:\Users\Admin\Desktop\

The above command will copy the file in Linux from the specified path to the Windows desktop.

Copy File from Windows To Linux Using FTP GUI

If you are not familiar with the Windows command line, you can use an FTP tool like Filezilla.

This tool is really helpful if you are working with Web Hosting providers to upload your website files from your local workstation.

You can download Filezilla from here –> FileZilla Download.

After download, install Filzill as you install any other windows software.

After installation, open the Filezilla app and enter the remote Linux server details as shown below. It will connect to the server and shows the remote server files in the file explorer.

Transfer files from windows to Linux using FTP

To upload a file, all you have to do is do a right-click and click upload, as shown in the image below. The file will get uploaded to the remote path, which is opened in the Filezilla explorer. You can also change the remote path from Filezilla.

Upload files from windows to Linux using Filezilla

Conclusion

I have shown two best and recommended ways to transfer files from Windows to Linux and vice versa.

If you face any issues while copying files, please drop the issues as a comment. I will look into it.

1 Shares:
3 comments
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like