In this article, we’re going to explain how to copy files from Windows PC to Linux to share files and folders between the operating systems. So read on to know more!
How to Copy Files from Windows PC to Linux
If you are a multi-OS user, sometimes you need access to the files stored in the other OS. For instance, if you use a Windows PC and want to access those files from your Linux distribution, you will need a mechanism to access those files. One of the easiest methods is to copy the files.
There are multiple ways to transfer files between the OS. In this guide, we will discuss four particular methods in detail.
Copy Files from Windows PC to Linux Using SSH
Copying files from Windows PC to Linux requires SSH configuration on Linux and PuTTY configuration on Windows. Hence, we have divided this section into two parts. The first part covers SSH configuration on Linux, and the second part describes how to set up PuTTY on Windows to transfer files.
Setup SSH to Copy Files from Windows to Linux
The most common method to transfer files securely between Windows and Linux is to use the SSH protocol. For this method, we will configure the SSH on Linux. Follow these simple steps to copy the files effortlessly.
First, configure SSH on ubuntu using the APT package manager. Open the Terminal by pressing “Ctrl + Alt + T” Execute the command given below:
sudo apt update sudo apt install openssh-server
After that, allow SSH through the UFW firewall. Specifically, type:
sudo ufw allow 22
You should get a similar output:
The output indicates that the rule already exists.
Now, to ensure that the SSH service is running on the Linux machine, execute this command:
sudo systemctl status sshd
Next, enable the service to boot at startup time. For this step, use the
start command as shown below:
sudo systemctl start sshd
Since transferring files requires the IP address of the destination system, we will find that out as well. Type the following command in the terminal and note the Public IP address:
The output should look something like this:
Setup PuTTY to Copy Files from Windows to Linux
Head over to Windows and open PuTTY. If you do not have PuTTY installed, download it from its official website. And install it like any other application. Once the installation is complete, launch the application. It should look something like this:
Type the IP address and port of the Linux system. Also, check the SSH option. Hit the “Enter” key to open the connection to the Linux system.
Now to transfer the files, use the
scp command. The syntax for this command looks something like this:
C:\Program Files\PuTTY>scp <File path in windows> username@ubuntuserverip:linuxserverpath
For instance, to transfer a textFile.txt from Local Disk D to /home/sidrah, type:
C:\Program Files\PuTTY>scp D:/txtFile.txt root@ipaddress:/home/sidrah/
Alternatively, you can use the wildcard pattern to transfer multiple files straightaway. The asterisk “
*” wildcard transfers all the contents inside the Images folder. For example:
Eg: C:\Program Files\PuTTY>scp D:/Images/* root@ipaddress:/home/usr/Images
You will be asked for the password to the Linux machine. Provide the correct password, and you will see the files being transferred.
Copy Files Using PSCP
Apart from SSH and PuTTY, you can also use pscp to copy files to/from Windows and Linux. Follow the step given below to transfer files using pscp.
The first step is to download the appropriate pscp package for Windows. Secondly, copy the pscp.exe from your downloads folder to the C:\Windows\System32 folder. After that, open Windows PowerShell (it is installed by default) and use the
pscp command to verify its path.
After that, use this command to transfer files to Linux:
pscp -pw password C:\Users\Sidrah\Desktop\testFile.txt \ [email protected]:/home/sidrah
pscp command takes the following arguments:
- The password to the Linux system (usually written after the
- The path where the file resides.
- The IP address of the Linux machine.
- The accessible path where the file will be copied.
After that, your file should be copied immediately when you press the “Enter” key.
In case you are using the RSA private/public key pair, the command should look something like this:
pscp -i /path/to/key.ppk C:\Users\Sidrah\Desktop\test.txt \ [email protected]:/home/sidrah
Copy File from Windows PC to Linux Using FTP GUI
If you are more comfortable with GUI than a Terminal, use the file transfer tool with a GUI (i.e., FileZilla). FileZilla utilizes the SFTP (Secure File Transfer Protocol) to transfer data between Windows and Linux securely. To get started, download FileZilla from its official website. Also, make sure to choose the appropriate setup according to your OS.
After that, install it in Windows like you would install any other software. Once the installation is complete, launch the application. Click Site Manager > New Site. A dialogue box will open:
Enter Hostname and set the protocol to SFTP. Enter 22 in the Port field, set the Log on Type to Normal, and type “User and Password”. Next, click “Connect”. You should see a file explorer with a file transfer option, as shown below:
Right-click on any item and click “Upload” to transfer the files. Like SSH and PuTTY, SFTP clients must be installed on both machines for successful file transfer. Therefore, you should install FileZilla on Linux as well as Windows.
Method # 4: Copy Files Using Shared Network Folders
It is the most straightforward approach to transferring files between machines. However, the approach is unique as you don’t have to use any protocol or client to transfer the files. Instead, you mount the drive over the network consisting of the shared files and folders. To set up this approach, follow these steps:
In Windows Machine, right-click on the “Network icon” to open a menu bar.
Select Open “Network & Internet Setting”. From Settings, choose “Network and Sharing Center”. Click to “Turn on Network Discovery and File and Printer Sharing”. Save the changes and exit Settings.
Next, head over to the folder you want to share. Right-click on the folder and choose “Properties”.
From the dialogue box, open the Sharing tab and Click “Advanced Sharing”. Click on the checkbox to share this folder. Click “OK” to save and apply the settings.
Now, open the Linux machine and select Network. Navigate to Files > Other Locations. There, you will see the Windows-Hosted folder available at your disposal for shared access.
We have discussed how to copy files from Windows PC to Linux in four different ways. Moreover, you can also choose any third-party application to copy files from Windows to Linux apart from the methods discussed in the article. If you have any problems while copying files, don’t hesitate to leave comments below.
If this guide helped you, please share it.