Featured image of post Uploading Files from Windows to Linux via Command Line (cmd)

Uploading Files from Windows to Linux via Command Line (cmd)

Background: I encountered an issue while uploading large files using MobXterm SFTP where files larger than 64GB would not upload past 64GB...

Background: While using MobXterm SFTP to upload large files, I faced a problem where files larger than 64GB stopped uploading once they reached that limit. So I switched to using the SCP command in the Windows command line. Indeed, sometimes the most basic tools work best, haha…

To upload and download files or folders to a Linux system from the Windows command line, you can use the SCP command. SCP stands for Secure Copy Protocol, which allows file transfer between local and remote hosts over the SSH protocol.

Here are the steps for uploading and downloading files or folders:

Uploading Files or Folders

Uploading a Single Local File

  1. Open the Windows command line and enter the following command:
1
scp <file_path> <username>@<linux_ip>:<remote_path>

Here, <file_path> is the path of the file or folder you want to upload, <username> is the username for the Linux system, <linux_ip> is the IP address of the Linux system, and <remote_path> is the target path on the Linux system.

For example, to upload the local file example.txt to the /home/user directory on the Linux system, you can enter the following command:

1
scp C:\Users\user\Documents\example.txt [email protected]:/home/user/

Uploading Files from Windows to Linux via Command Line (cmd)

Uploading a Whole Local Folder

To upload a folder, you can use the -r option, like this:

1
scp -r C:\Users\user\Documents\example_folder [email protected]:/home/user/
  1. Enter the password for the Linux system and press Enter.
  2. SCP will automatically upload the file or folder to the specified directory on the Linux system.

Download Operations

Downloading a Single File

  1. Open the Windows command line and enter the following command:
1
scp <username>@<linux_ip>:<remote_path> <local_path>

Here, <username> is the username for the Linux system, <linux_ip> is the IP address of the Linux system, <remote_path> is the path to the file or folder on the Linux system, and <local_path> is the path where you want to save the file or folder locally.

For example, to download the file /home/user/example.txt from the Linux system to the C:\Users\user\Documents directory on your local machine, you can enter the following command:

1
scp [email protected]:/home/user/example.txt C:\Users\user\Documents\

Downloading an Entire Folder

If you want to download a folder, you can also use the -r option, like this:

1
scp -r [email protected]:/home/user/example_folder C:\Users\user\Documents\
  1. Enter the password for the Linux system and press Enter.
  2. SCP will automatically download the file or folder to the specified local directory.
Licensed under CC BY-NC-SA 4.0