How to copy file from Windows to Linux using command line?

27 Dec, 22 by Oliver K 3 min Read

How to copy file from Windows to Linux using command line?

List of content you will read in this article:

If you have a connected, working, and tested Linux Server and you are looking to transfer files from windows to a Linux server. You can do that; however, it is not as simple as you think. It is well known that working with servers, especially those running a command line interface, can be somewhat burdensome.

In this article, we will help you to upload local files from a Windows to a Linux VPS, whereas if you want to transfer data from a Windows pc to a Windows server, you can read this blog post.

Steps to Transfer a File From Windows to Linux Server

To understand the concept, The Windows PC you are transferring the files from will be referred to as the source, and the Linux Server you are transferring the files to will be referred to as the destination. For demonstration purposes, we have created a file on the desktop named “test.txt”.

How to copy file from Windows to Linux using command line?

Follow these simple steps to transfer files from a Windows to Linux server:

Step 1: Open “Run” by pressing the Windows key +R on your keyboard simultaneously or by typing run into the search bar.

Step 2: Type cmd in the open run window and press Enter.

How to copy file from Windows to Linux using command line?

Step 3: Enter the file's directory by typing cd followed by the file path. (In this case, the file is on the desktop, so we write cd desktop).

Step 4: Use the “SCP” command in the same format as shown below to upload the file.

SCP filename.extension username@serveraddress:filepath

Where:

  • filename.extension: It is the name of the file and its extension (test.txt in our case)
  • username: It is the username used to connect to VPS (root in our case)
  • serveraddress: It is the IP address of the VPS or server
  • filepath: It is the path where you want the file to be copied to (/etc/ssh in our case)

How to copy file from Windows to Linux using command line?

Step 5: If this is your first time connecting to the server, Windows will ask you to accept the security alert. Please do so.

Step 6: Next, you will have to enter the destination server's password.

How to copy file from Windows to Linux using command line?

And that’s it! Once the correct password has been entered, your file will be uploaded.

To verify that file is transferred, open putty and connect to the destination server. Use “Nano editor” or “vi” editor to open the file.

How to copy file from Windows to Linux using command line?

As can be seen in the following image, the file has been uploaded and is available on the server.

How to copy file from Windows to Linux using command line?

There is also a popular way to transfer files from windows to Linux server or vice versa with the help of WinSCP software. this is an alternate or easy solutions to complete your job.

Conclusion

Unfortunately, there is no simple way than WCP Software for drag-and-drop that we suggested above to upload/transfer files from a Windows VPS server to a Linux server. To be able to do or manage the virtual private server, you will need to learn how to use the command-line interface. Nevertheless, once you know how to do it, it is not much more complex than using your PC for your typical daily tasks. We hope that with the help of this article, you were able to help with the guideline that you are looking for. If you have any questions or suggestions, please leave them in the comment section listed below.

People Are Also Reading:

  • How to Secure Linux Server? [Linux Hardening]
  • How to Change Linux Password?
  • Centos/Debian/Ubuntu/Linux File Permissions
  • How to check Linux Version?
  • How to Create a Folder in Linux?
  • How to Find File in Linux?

A great many people are confused about how to transfer files from Windows to Linux. If you are also trying to figure it out, this post of MiniTool is worth reading. It introduces 5 feasible ways for copying files from Windows to Linux.

On This Page :

Have you ever made a switch between different operating systems like Windows to Linux? If the answer is yes, you may wonder how to transfer files from Windows to Linux. Copying files from Windows to Linux or back again won’t be difficult via the following 5 ways. Here you can try them in order or choose one that works best for you.

# 1. Transfer Files from Windows to Linux via SSH

SSH (Secure Shell) is a remote administration protocol that allows you to control and modify your servers over the internet. It’s also a cryptographic network protocol that enables you to use network services safely even through an unsecured network.

With SSH enabled on your computers, you can transfer file from Windows to Linux via the command line. Here’s how to do that:

Step 1. Update the Linux OS on your computer.

1. On your Linux device, open a terminal window/command line by using the Ctrl + Alt + T or Ctrl + Alt + F2 key combinations.

2. In the terminal window, execute the following command to update your local repositories.

sudo apt-get update

How to copy file from Windows to Linux using command line?

Step 2. Install the OpenSSH server.

1. You can install the SSH server via the OpenSSH server, which can eliminate all potential threats to your data. Run the following command in the terminal window to install the OpenSSH server.

sudo apt install openssh-server

How to copy file from Windows to Linux using command line?

2. Wait for the installation to complete. Then you can run the following command to check if the OpenSSH server is installed properly.

sudo service ssh status

Step 3. Install an SSH client like PuTTY on Windows.

PuTTY is an SSH client that can help you copy a file from Linux to Windows freely between different networks. To run alongside PuTTY, you need to get the PSCP (secure copy client) tool on Windows.

Tips:

You just need to manually install PuTTY on Windows., but he PSCP doesn't have to install and you can save the downloaded pscp.exe file on the C drive.

1. Click here to open the PuTTY download page, select a version according to your system and click on the blue link to download it.

How to copy file from Windows to Linux using command line?

2. Double-click the PuTTY install to run it and click on Next, save the exe file in the root of the Windows C:\ drive and click on Next.

How to copy file from Windows to Linux using command line?

3. Click on Install to start installing PuTTY on your Windows PC.

How to copy file from Windows to Linux using command line?

Step 4. Start copying files from Windows to Linux.

  1. Confirm the IP address of your Linux device by running the hostname -I command in the terminal window.
  2. Make sure you have a connection established. Then you can copy files from Windows to Linux using the following code.

Tips:

Make sure to replace remoteIP: with the IP address of your Linux device.

c:\pscp c:

ome\path\to\a\file.txt [email protected]:\home\user

ome\path

ewname.txt

  1. Before the transfer, you need to input your Linux computer password for copying files from Windows to Linux.
  2. If you want to copy a specific file like file.txt in Windows to a directory like temp in Linux, you can run the following command.

C:\Program Files\PuTTY>pscp \Users\user\file.txt [email protected]:/temp

  1. If you want to copy file from Linux to Windows, you can reverse the command.

C:\Program Files\PuTTY>pscp [email protected]:/temp/file.txt \Users\user

# 2. Transfer Files from Windows to Linux via FTP

FTP (File Transfer Protocol) is a standard network protocol designed to transfer computer files between clients and servers on a computer network. This tool can help you transfer a file from Windows to Linux without typing any commands.

Before you do, you need to install an SFTP-supported app on Windows like FileZilla and make sure your Linux server is running for this method. Then you can follow the steps below to copy Windows files to Linux.

Step 1. Launch the FileZilla app on Windows, and then select File > Site Manager from the upper left corner.

How to copy file from Windows to Linux using command line?

Step 2. Select the site folder and click on New Site and change the Protocol to SFTP.

Step 3. Input the target IP address of your Linux server next to the Host box.

Step 4. Add your username and password, and change the Logon Type to Normal.

Step 5. Once done, click on Connect.

How to copy file from Windows to Linux using command line?

Now, you can use the FTP app for transferring files from Windows to Linux back using drag and drop.

# 3. Transfer Files from Windows to Linux via Virtual Machine

If you are running Linux in a VM on Windows or vice versa, you can transfer file from Windows to Linux by running one of your systems on the VM. The program can be used to create a virtual shared directory for data syncing.

To do this work, you need to have a VM app like Oracle VM VirtualBox installed on your PC. Here’s how to transfer files to Linux from Windows via the VM.

Step 1. Launch the VM VirtualBox app on your PC, and then select Start > Headless Start.

How to copy file from Windows to Linux using command line?

Step 2. When the app is running, right-click the VM and select Settings > Shared Folder > Machine Folders.

Step 3. Click on the “+” icon at the upper right corner and select Add Shared Folder.

Step 4. Select the Folder Path and locate the directory that you want to transfer.

Step 5. Set the Folder Name if necessary, and tick the checkbox next to Auto-mount to ensure the shared folder is available when you run the VM.

Step 6. Click on OK to save the change and exit.

How to copy file from Windows to Linux using command line?

Step 7. Restart your Virtual Machine and the shared folder will be ready to transfer data between your host PC and the Guest OS. Then you can copy a file from Linux to Windows or vice versa.

# 4. Transfer Files from Windows to Linux via Sync Software

You can consider using a Sync software app like Resilio and SyncThing for transferring files from Windows to Linux. This tool can be used to manage the connection between two operating systems or devices with an encrypted key.

With the Sync software, all thing you need to do is install the app on the first PC, choose a sync folder, and create the encrypted key. Then set up this app on the second PC and your data can be synced between Windows and Linux.

In addition, you can create a shared network folder on one or both systems and then copy Windows files to Linux or vice versa across a network. That’s to say, this method will allow you to share the same files/folders in both Windows and Linux simultaneously. Well, the operation may fail if your network is unreliable, but it’s having a try.

Step 1. On Windows, right-click the network connection icon from the system tray and select Open Network & Internet Settings > Network and Sharing Center.

How to copy file from Windows to Linux using command line?

Step 2. Select Change advanced sharing settings and enable the following 2 options, and click on Save Changes.

  • Turn on network discovery
  • Turn on file and printer sharing
How to copy file from Windows to Linux using command line?

Step 3. Navigate to the target that you want to transfer a file from Windows to Linux, right-click the folder, and select Properties.

Step 4. In the Properties window, go to the Sharing tab and click on Advanced Sharing, and select the checkbox for Share this folder. Also, you can click on Permissions to manage the permissions.

Step 5. Click on Apply and then on OK to save the changes.

How to copy file from Windows to Linux using command line?

Step 6. To copy files from Windows to Linux, simply open the file explorer of your Linux device and select Network. Then locate the Windows-hosted folder and start copying files from Windows to Linux.

If you want to transfer a folder from Linux to Windows, you can use a tool that can emulate the Windows protocols in Linux, allowing you to share files with Windows.

Further Reading: Do you want to manage your partition and disk on Windows effectively? MiniTool Partition Wizard is a good choice that can help you extend/resize/delete partition, convert a disk to MBR/GPT, migrate OS, etc.

How to copy file from Windows to Linux using SCP command?

Select the File Protocol from the drop-down list as SCP first. Add the IP address of Ubuntu within the “Hostname” field. Add user name and password to connect and press Login. After a successful connection, drag the files from the left area to the right side of WinSCP to transfer.

How to copy file from Windows to Linux using PuTTY command

You can use PSCP to copy files from Windows to Linux..
Download PSCP from putty.org..
Open cmd in the directory with pscp.exe file..
Type command pscp source_file user@host:destination_file. Ex. pscp sample.txt [email protected]:/mydata/sample.txt..

How to copy files from Windows to Ubuntu command

i. Start Ubuntu..
ii. Open Terminal..
iii. Ubuntu Terminal..
iv. Install OpenSSH Server and Client..
v. Supply Password..
OpenSSH will be installed..
Check the IP address with ifconfig command..
IP address..