In this updated guide, I will walk you through the steps to copy files between Windows and Linux using easy-to-follow steps.
I will show you two ways to copy files from Windows to Linux
- Using the command line with psc
- 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.
Step 1: Download pscp.exe from here. Select the appropriate package.
Step 2: Copy the pscp.exe executable to the system32 directory of your Windows machine. This folder normally exists in C:\Windows\System32 the path.
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.
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.
-pw
for the password.- Replace
password
with the Linux user password. C:\Users\Admin\Desktop\test.txt
represents the path of the file that has to be copied to the Linux system.192.168.33.10
is the IP of the Linux server./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 putty gen command to convert it to PPK. See this ec2 server guide for the pem 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 downloading, 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 show the remote server files in the file explorer.
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.
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.
5 comments
Your article is very informative. it’s really helpful……
Hey Mike,
Thanks for the tutorial. You should fix the download link to pscp.exe.
Cheers!
Thanks a lot for the tutorial, I was looking for this through several pages without luck!
👍Thanks for the tutorial
Very very helpful. Please post more like this.