Sync files from windows to linux

Synchronizing files between Linux and Windows can seem challenging, especially if you’re not familiar with the tools available. However, with the Windows Subsystem for Linux (WSL), this process becomes much simpler.

WSL allows you to run a Linux environment directly on Windows, enabling you to use powerful Linux tools like Rsync to sync files between the two operating systems.

In this article, we’ll walk you through the entire process of using Rsync to sync files between Linux and Windows using WSL. We’ll cover everything from setting up WSL to writing scripts for automated syncing.

By the end, you’ll have a clear understanding of how to efficiently manage file synchronization across these two platforms.

What is Rsync?

Rsync (short for “remote synchronization“) is a command-line tool used to synchronize files and directories between two locations, which is highly efficient because it only transfers the changes made to files, rather than copying everything every time, which makes it ideal for syncing large files or large numbers of files.

Why Use Rsync with WSL?

  • WSL allows you to run Linux commands and tools directly on Windows, making it easier to use Rsync.
  • Rsync only transfers the differences between files, saving time and bandwidth.
  • You can sync files between a Linux machine and a Windows machine effortlessly.
  • Rsync can be automated using scripts, making it perfect for regular backups or syncing tasks.

Prerequisites

Before we begin, ensure you have the following:

  • WSL is supported on versions of Windows 10 and 11.
  • You need to have WSL installed and set up on your Windows machine.
  • Install a Linux distribution (e.g., Ubuntu) from the Microsoft Store.
  • Rsync is usually pre-installed on Linux distributions, but we’ll cover how to install it if it’s not.
  • Rsync uses SSH to securely transfer files between systems.

Step 1: Install and Set Up WSL

If you haven’t already installed WSL, then open PowerShell as administrator by pressing Win + X and selecting “Windows PowerShell (Admin)” or “Command Prompt (Admin)” and run the following command to install WSL.

wsl --install

This command installs WSL and the default Linux distribution (usually Ubuntu). After installation, restart your computer to complete the setup.

Once your computer restarts, open the installed Linux distribution (e.g., Ubuntu) from the Start menu. Follow the on-screen instructions to create a user account and set a password.

Step 2: Install Rsync on WSL

Rsync is usually pre-installed on most Linux distributions. However, if it’s not installed, you can install it using the following commands.

sudo apt update
sudo apt install rsync
rsync --version

This should display the installed version of Rsync.

Step 3: Set Up SSH on WSL

To enable SSH on WSL, you need to install the OpenSSH server.

sudo apt install openssh-server

Next, start and enable the SSH service to start automatically every time you launch WSL.

sudo service ssh start
sudo systemctl enable ssh

Verify that the SSH service is running.

sudo service ssh status

Step 4: Sync Files from Linux (WSL) to Windows

Now that Rsync and SSH are set up, you can start syncing files. Let’s say you want to sync files from your WSL environment to a directory on your Windows machine.

Launch your Linux distribution (e.g., Ubuntu) and identify the Windows directory, which typically mounted under /mnt/. For example, your C: drive is located at /mnt/c/.

Now run the following command to sync files from your WSL directory to a Windows directory:

rsync -avz /path/to/source/ /mnt/c/path/to/destination/

Explanation of the command:

  • -a: Archive mode (preserves permissions, timestamps, and symbolic links).
  • -v: Verbose mode (provides detailed output).
  • -z: Compresses data during transfer.
  • /path/to/source/: The directory in your WSL environment that you want to sync.
  • /mnt/c/path/to/destination/: The directory on your Windows machine where you want to sync the files.

Step 5: Sync Files from Windows to Linux (WSL)

If you want to sync files from a Windows directory to your WSL environment, you can use a similar command:

rsync -avz /mnt/c/path/to/source/ /path/to/destination/

Explanation of the command:

  • /mnt/c/path/to/source/: The directory on your Windows machine that you want to sync.
  • /path/to/destination/: The directory in your WSL environment where you want to sync the files.

Step 6: Automate Syncing with a Script

To make syncing easier, you can create a bash script to automate the process.

nano sync.sh

Add the following lines to the script:

#!/bin/bash
rsync -avz /path/to/source/ /mnt/c/path/to/destination/

Save the file and make the script executable:

chmod +x sync.sh

Execute the script to sync files.

./sync.sh

You can use cron to schedule the script to run at specific intervals. For example, to run the script every day at 2 AM, add the following line to your crontab:

0 2 * * * /path/to/sync.sh
Conclusion

Using Rsync with WSL is a powerful and efficient way to sync files between Linux and Windows. By following the steps outlined in this article, you can easily set up Rsync, configure SSH, and automate file synchronization.

CDC File Transfer

Born from the ashes of Stadia, this repository contains tools for syncing and
streaming files from Windows to Windows or Linux. The tools are based on Content
Defined Chunking (CDC), in particular
FastCDC,
to split up files into chunks.

History

At Stadia, game developers had access to Linux cloud instances to run games.
Most developers wrote their games on Windows, though. Therefore, they needed a
way to make them available on the remote Linux instance.

As developers had SSH access to those instances, they could use scp to copy
the game content. However, this was impractical, especially with the shift to
working from home during the pandemic with sub-par internet connections. scp
always copies full files, there is no «delta mode» to copy only the things that
changed, it is slow for many small files, and there is no fast compression.

To help this situation, we developed two tools, cdc_rsync and cdc_stream,
which enable developers to quickly iterate on their games without repeatedly
incurring the cost of transmitting dozens of GBs.

CDC RSync

cdc_rsync is a tool to sync files from a Windows machine to a Linux device,
similar to the standard Linux rsync. It is
basically a copy tool, but optimized for the case where there is already an old
version of the files available in the target directory.

  • It quickly skips files if timestamp and file size match.
  • It uses fast compression for all data transfer.
  • If a file changed, it determines which parts changed and only transfers the
    differences.

cdc_rsync demo

The remote diffing algorithm is based on CDC. In our tests, it is up to 30x
faster than the one used in rsync (1500 MB/s vs 50 MB/s).

The following chart shows a comparison of cdc_rsync and Linux rsync running
under Cygwin on Windows. The test data consists of 58 development builds
of some game provided to us for evaluation purposes. The builds are 40-45 GB
large. For this experiment, we uploaded the first build, then synced the second
build with each of the two tools and measured the time. For example, syncing
from build 1 to build 2 took 210 seconds with the Cygwin rsync, but only 75
seconds with cdc_rsync. The three outliers are probably feature drops from
another development branch, where the delta was much higher. Overall,
cdc_rsync syncs files about 3 times faster than Cygwin rsync.

Comparison of cdc_rsync and Linux rsync running in Cygwin

We also ran the experiment with the native Linux rsync, i.e syncing Linux to
Linux, to rule out issues with Cygwin. Linux rsync performed on average 35%
worse than Cygwin rsync, which can be attributed to CPU differences. We did
not include it in the figure because of this, but you can find it
here.

How does it work and why is it faster?

The standard Linux rsync splits a file into fixed-size chunks of typically
several KB.

If the file is modified in the middle, e.g. by inserting xxxx after 567,
this usually means that the modified chunks as well as
all subsequent chunks
change.

The standard rsync algorithm hashes the chunks of the remote «old» file
and sends the hashes to the local device. The local device then figures out
which parts of the «new» file matches known chunks.

Syncing a file with the standard Linux rsync

Standard rsync algorithm

This is a simplification. The actual algorithm is more complicated and uses
two hashes, a weak rolling hash and a strong hash, see
here for a great overview. What makes
rsync relatively slow is the «no match» situation where the rolling hash does
not match any remote hash, and the algorithm has to roll the hash forward and
perform a hash map lookup for each byte. rsync goes to
great lengths
optimizing lookups.

cdc_rsync does not use fixed-size chunks, but instead variable-size,
content-defined chunks. That means, chunk boundaries are determined by the
local content of the file, in practice a 64 byte sliding window. For more
details, see
the FastCDC paper
or take a look at our implementation.

If the file is modified in the middle, only the modified
chunks
, but not subsequent chunks
change (unless they are less than 64 bytes away from the modifications).

Computing the chunk boundaries is cheap and involves only a left-shift, a memory
lookup, an add and an and operation for each input byte. This is cheaper
than the hash map lookup for the standard rsync algorithm.

Because of this, the cdc_rsync algorithm is faster than the standard
rsync. It is also simpler. Since chunk boundaries move along with insertions
or deletions, the task to match local and remote hashes is a trivial set
difference operation. It does not involve a per-byte hash map lookup.

Syncing a file with cdc_rsync

cdc_rsync algorithm

CDC Stream

cdc_stream is a tool to stream files and directories from a Windows machine to
a Linux device. Conceptually, it is similar to
sshfs, but it is optimized for read speed.

  • It caches streamed data on the Linux device.
  • If a file is re-read on Linux after it changed on Windows, only the
    differences are streamed again. The rest is read from the cache.
  • Stat operations are very fast since the directory metadata (filenames,
    permissions etc.) is provided in a streaming-friendly way.

To efficiently determine which parts of a file changed, the tool uses the same
CDC-based diffing algorithm as cdc_rsync. Changes to Windows files are almost
immediately reflected on Linux, with a delay of roughly (0.5s + 0.7s x total
size of changed files in GB).

cdc_stream demo

The tool does not support writing files back from Linux to Windows; the Linux
directory is readonly.

The following chart compares times from starting a game to reaching the menu.
In one case, the game is streamed via sshfs, in the other case we use
cdc_stream. Overall, we see a 2x to 5x speedup.

Comparison of cdc_stream and sshfs

Supported Platforms

cdc_rsync From To
Windows x86_64 1
Ubuntu 22.04 x86_64 2
Ubuntu 22.04 aarch64
macOS 13 x86_64 3
macOS 13 aarch64 3
cdc_stream From To
Windows x86_64
Ubuntu 22.04 x86_64
Ubuntu 22.04 aarch64
macOS 13 x86_64 3
macOS 13 aarch64 3

1 Only local syncs, e.g. cdc_rsync C:\src\* C:\dst. Support for
remote syncs is being added, see
#61.
2 See #56.
3 See #62.

Getting Started

Download the precompiled binaries from the
latest release to a
Windows device and unzip them. The Linux binaries are automatically deployed
to ~/.cache/cdc-file-transfer by the Windows tools. There is no need to manually
deploy them. We currently provide Linux binaries compiled on
Github’s latest Ubuntu version.
If the binaries work for you, you can skip the following two sections.

Alternatively, the project can be built from source. Some binaries have to be
built on Windows, some on Linux.

Prerequisites for Building

To build the tools from source, the following steps have to be executed on
both Windows and Linux.

  • Download and install Bazel from here. See
    workflow logs for the
    currently used version.
  • Clone the repository.
    git clone https://github.com/google/cdc-file-transfer
    
  • Initialize submodules.
    cd cdc-file-transfer
    git submodule update --init --recursive
    

Finally, install an SSH client on the Windows machine if not present.
The file transfer tools require ssh.exe and sftp.exe.

Building

The two tools CDC RSync and CDC Stream can be built and used independently.

CDC RSync

  • On a Linux device, build the Linux components
    bazel build --config linux --compilation_mode=opt --linkopt=-Wl,--strip-all --copt=-fdata-sections --copt=-ffunction-sections --linkopt=-Wl,--gc-sections //cdc_rsync_server
    
  • On a Windows device, build the Windows components
    bazel build --config windows --compilation_mode=opt --copt=/GL //cdc_rsync
    
  • Copy the Linux build output file cdc_rsync_server from
    bazel-bin/cdc_rsync_server to bazel-bin\cdc_rsync on the Windows machine.

CDC Stream

  • On a Linux device, build the Linux components
    bazel build --config linux --compilation_mode=opt --linkopt=-Wl,--strip-all --copt=-fdata-sections --copt=-ffunction-sections --linkopt=-Wl,--gc-sections //cdc_fuse_fs
    
  • On a Windows device, build the Windows components
    bazel build --config windows --compilation_mode=opt --copt=/GL //cdc_stream
    
  • Copy the Linux build output files cdc_fuse_fs and libfuse.so from
    bazel-bin/cdc_fuse_fs to bazel-bin\cdc_stream on the Windows machine.

Usage

The tools require a setup where you can use SSH and SFTP from the Windows
machine to the Linux device without entering a password, e.g. by using key-based
authentication.

Configuring SSH and SFTP

By default, the tools search ssh.exe and sftp.exe from the path environment
variable. If you can run the following commands in a Windows cmd without
entering your password, you are all set:

ssh user@linux.device.com
sftp user@linux.device.com

Here, user is the Linux user and linux.device.com is the Linux host to
SSH into or copy the file to.

If additional arguments are required, it is recommended to provide an SSH config
file. By default, both ssh.exe and sftp.exe use the file at
%USERPROFILE%\.ssh\config on Windows, if it exists. A possible config file
that sets a username, a port, an identity file and a known host file could look
as follows:

Host linux_device
	HostName linux.device.com
	User user
	Port 12345
	IdentityFile C:\path\to\id_rsa
	UserKnownHostsFile C:\path\to\known_hosts

If ssh.exe or sftp.exe cannot be found, you can specify the full paths via
the command line arguments --ssh-command and --sftp-command for cdc_rsync
and cdc_stream start (see below), or set the environment variables
CDC_SSH_COMMAND and CDC_SFTP_COMMAND, e.g.

set CDC_SSH_COMMAND="C:\path with space\to\ssh.exe"
set CDC_SFTP_COMMAND="C:\path with space\to\sftp.exe"

Note that you can also specify SSH configuration via the environment variables
instead of using a config file:

set CDC_SSH_COMMAND=C:\path\to\ssh.exe -p 12345 -i C:\path\to\id_rsa -oUserKnownHostsFile=C:\path\to\known_hosts
set CDC_SFTP_COMMAND=C:\path\to\sftp.exe -P 12345 -i C:\path\to\id_rsa -oUserKnownHostsFile=C:\path\to\known_hosts

Note the small -p for ssh.exe and the capital -P for sftp.exe.

Google Specific

For Google internal usage, set the following environment variables to enable SSH
authentication using a Google security key:

set CDC_SSH_COMMAND=C:\gnubby\bin\ssh.exe
set CDC_SFTP_COMMAND=C:\gnubby\bin\sftp.exe

Note that you will have to touch the security key multiple times during the
first run. Subsequent runs only require a single touch.

CDC RSync

cdc_rsync is used similar to scp or the Linux rsync command. To sync a
single Windows file C:\path\to\file.txt to the home directory ~ on the Linux
device linux.device.com, run

cdc_rsync C:\path\to\file.txt user@linux.device.com:~

cdc_rsync understands the usual Windows wildcards * and ?.

cdc_rsync C:\path\to\*.txt user@linux.device.com:~

To sync the contents of the Windows directory C:\path\to\assets recursively to
~/assets on the Linux device, run

cdc_rsync C:\path\to\assets\* user@linux.device.com:~/assets -r

To get per file progress, add -v:

cdc_rsync C:\path\to\assets\* user@linux.device.com:~/assets -vr

The tool also supports local syncs:

cdc_rsync C:\path\to\assets\* C:\path\to\destination -vr

CDC Stream

To stream the Windows directory C:\path\to\assets to ~/assets on the Linux
device, run

cdc_stream start C:\path\to\assets user@linux.device.com:~/assets

This makes all files and directories in C:\path\to\assets available on
~/assets immediately, as if it were a local copy. However, data is streamed
from Windows to Linux as files are accessed.

To stop the streaming session, enter

cdc_stream stop user@linux.device.com:~/assets

The command also accepts wildcards. For instance,

stops all existing streaming sessions for the given user.

Troubleshooting

On first run, cdc_stream starts a background service, which does all the work.
The cdc_stream start and cdc_stream stop commands are just RPC clients that
talk to the service.

The service logs to %APPDATA%\cdc-file-transfer\logs by default. The logs are
useful to investigate issues with asset streaming. To pass custom arguments, or
to debug the service, create a JSON config file at
%APPDATA%\cdc-file-transfer\cdc_stream.json with command line flags.
For instance,

instructs the service to log debug messages. Try cdc_stream start-service -h
for a list of available flags. Alternatively, run the service manually with

and pass the flags as command line arguments. When you run the service manually,
the flag --log-to-stdout is particularly useful as it logs to the console
instead of to the file.

cdc_rsync always logs to the console. To increase log verbosity, pass -vvv
for debug logs or -vvvv for verbose logs.

For both sync and stream, the debug logs contain all SSH and SFTP commands that
are attempted to run, which is very useful for troubleshooting. If a command
fails unexpectedly, copy it and run it in isolation. Pass -vv or -vvv for
additional debug output.

Want to use both Windows and Linux but want to keep all your files in sync? Whether you prefer automatic background syncing or manual control, these cross-platform tools offer secure, efficient solutions for keeping your data synchronized across operating systems.

5

Syncthing: Automated Peer-to-Peer Syncing

Syncthing is a powerful synchronization tool built with privacy and automation in mind. At its core, it offers peer-to-peer file synchronization that keeps your files in-sync across multiple devices without relying on a central server. This means that once you add, remove, or edit a file on one device, changes are instantly synced on the connected device without involving any intermediary storage providers, making sure your data stays secure and under your control.

What makes Syncthing particularly compelling is its approach to continuous synchronization. Once set up, it works silently in the background, monitoring your chosen folders for changes and syncing any changes between your devices in real-time. The tool also employs strong encryption by default, so you don’t need to worry about hackers sniffing your data.

Syncthing WebUI on Windows PC after a fresh install.

Syncthing is my favorite sync tool and what I use. I not only use it to sync files between my Windows and Linux systems, but also to sync Obsidian notes between my Windows PC and Android phone.

4

FreeFileSync: When Manual Control Matters

Selecting source and backup directories on FreeFileSync.

FreeFileSync takes a fundamentally different approach to file synchronization when compared to Syncthing. Instead of automatic background synchronization, FreeFileSync offers a visual and manual syncing solution. You get a graphical interface that lets you see and choose exactly what files are getting synced between both devices and the syncing takes place only when you give the green signal.

The tool excels in its comparison capabilities, letting you see file differences side by side and make informed decisions about each sync operation. Where Syncthing works best for those who want a «set it and forget it» solution, FreeFileSync shines for users who need to carefully manage their synchronization process. It’s particularly valuable for one-time migrations or when you need to ensure specific files don’t accidentally sync to the wrong place.

It’s a great option for users who are looking for extra granular and manual control over what files are synced between their devices. With Syncthing, all your edits would get synced in real-time, but with FreeFileSync, you can sync the file only when you’re done editing and modifying it. This also makes it an excellent tool for backups.

3

Nextcloud: Deploy a Self-Hosted Cloud for Syncing

Nextcloud desktop syncing settings dialog.

Technically, Nextcloud is not a syncing tool but rather a file hosting system that lets you create your own cloud storage solution. It can be a bit complicated to set up, but what you get in return is a very powerful system that can do a lot of things, including file syncing. Ideally, you’d use a Raspberry Pi to host your Nextcloud server, but you can also use a VPS (Virtual Private Server). You can also host it locally, but note that the system needs to run 24/7 for your Nextcloud server to stay operational.

Once set up, you can create synchronized Nextcloud folders on your Windows and Linux PCs. Now, any changes you make to files in these folders automatically sync across to the other device through the Nextcloud server. For example, if you edit a document on your Windows PC, those changes will automatically appear on your Linux PC without any manual uploading or downloading. The server acts as a central hub, ensuring all your devices stay in sync with the latest version of your files.

The biggest benefit of syncing files like this is that the files are uploaded to your Nextcloud instance. This means that you can edit a file on your Windows PC, turn off the machine, and then open your Linux PC at a later hour and still find the updated file. This is not possible with peer-to-peer syncing solutions like Syncthing and FreeFileSync because both your Windows and Linux PC need to be running at the same time for the files to sync.

You can technically use OneDrive or Dropbox, similar to Nextcloud, for your file syncing needs. The main advantage Nextcloud has over those options is that you host your Nextcloud instance, which means only you (no third party) can access the data that goes through it.

2

rsync: For the Command Line Enthusiasts

Two terminals on a laptop screen, showing the man pages for the scp and rsync commands.

Kris Wouk / How-To Geek

Unlike all the other tools I discussed which give you a graphical user interface, you need to use the command line to work with rsync. However, if that’s alright with you, rsync gives you access to the most powerful, flexible, and efficient syncing tool available.

The tool’s defining feature is its delta-transfer algorithm, which makes it uniquely efficient at handling large files. Where Syncthing or FreeFileSync need to transfer complete files when changes occur, rsync intelligently transfers only the changed portions of files. This makes it extraordinarily bandwidth-efficient, especially for large files with small changes.

It also offers intelligent network resume capabilities, which means that if there’s a network issue or interruption to the transfer process, rsync can gracefully navigate the inconvenience and ensure your files are synced when network stability is restored.

Furthermore, as a command line utility, you can easily set up bash scripts with rsync and run automated syncing scenarios. That said, rsync is a command line utility that is only natively available on Linux, not on Windows. As such, to run rsync on a Windows system, you need to enable WSL (Windows Subsystem for Linux) and then install rsync in a virtualized Linux environment that still allows you to access your Windows files.

There is a graphical wrapper for rsync called Grsync that you can use if you find this tool exciting but hate using the command line. However, it only lets you access the basic and most common features of rsync with a point-and-click interface. For the advanced stuff, you will need to use the tool in the command line.

And last but not least, we have the trusty USB drive. Now, before you shout at me that copying files to a USB drive and transferring between PCs isn’t called syncing—I know! But what if you only had a single PC in a dual-booted configuration running multiple operating systems? In that case, solutions like Syncthing, FreeFileSync, or rsync will not work because all these tools require both systems to run at the same time for the syncing to happen. However, in a dual boot system, the two systems are never running at the same time.

samsung fit

Samsung Fit Plus USB 3.1 Flash Drive

If you need a well-rounded flash drive with good durability and fast performance, the Fit Plus is a great choice.

Now, Nextcloud is a solution for dual boot systems, but it’s a costly solution. You need to use a VPS, which is a paid monthly (or yearly) service, or you need to host it on a separate local system, which—in this example—you don’t have.

This is where a USB drive comes in. It’s super cheap; you probably have one lying around on your desk right now. You can simply plug it into your PC, and both Windows and Linux will read the files on the USB drive when you boot into the respective operating systems. This means you can start Windows, move a file to the USB drive that you want on Linux, close Windows, open Linux, and the file is there on the USB drive. Simple, elegant, and resourceful!


Whether you opt for Syncthing’s automated convenience, FreeFileSync’s manual control, Nextcloud’s self-hosted solution, rsync’s command-line power, or even a simple USB drive, the key is choosing a tool that fits your workflow. Each option offers distinct advantages for keeping your Windows and Linux systems synchronized efficiently.

Copying data from a Windows PC to Linux—or in the other direction—can seem intimidating at first. After all, it’s something that seems like it should be simple but turns out to be difficult.

In truth, sharing files from Windows to Linux is easy, but only if you know how to do it. Ready to find out? Here’s everything you need to know about how to transfer files from Windows to Linux and back again.

4 Ways to Transfer Files From Windows to Linux

If you want to move data between Windows and Linux operating systems, it’s easier than you think. We’ve compiled four ways for you to do this:

  1. Securely copy files via SSH
  2. Windows to Linux file transfer with FTP
  3. Share data using sync software
  4. Use shared folders in your Linux virtual machine

With each of these methods, you’ll be able to easily (and, in some cases, effortlessly) carry out Linux to Windows or Windows to Linux file transfer.

Let’s look at them in turn and find out which one suits you best.

1. Copy Files Between Windows and Linux via SSH

With SSH enabled on your Linux device, you can send data via the command line from one computer to another. For this to work, however, you will need to set up an SSH server on your Linux machine.

Start by opening a terminal and updating and upgrading the OS.

        sudo apt update
sudo apt upgrade

Once complete, install the SSH server. The OpenSSH server is a good option.

        sudo apt install openssh-server
    

Wait while it installs. To check at any time if the OpenSSH server is running, use:

        sudo service ssh status
    

To transfer data from Windows, use an SSH client like PuTTY. This needs the PSCP (secure copy client) tool to download to your Windows system to run alongside PuTTY. Find both on the PuTTY downloads page.

Download: PuTTY

Note that while PuTTY will need installing, PSCP won’t. Instead, save the downloaded pscp.exe file in the root of the Windows C:\ drive or else set it up as an environment variable. You’ll also need to confirm the IP address of the Linux device. Check in the Linux terminal with:

        hostname -I
    

With a connection established, you can transfer a file from Windows to Linux like this:

        c:\pscp c:\some\path\to\a\file.txt user@remoteIP:\home\user\some\path\newname.txt
    

You’ll be prompted for your password for the Linux computer before the transfer commences.

Want to copy files from Linux to Windows in the same SSH session? This command will download the specified file to the current directory:

        c:\pscp user@remoteIP:\home\user\some\file.txt .
    

Note the lone period at the end, which you must include, or the transfer will not work.

2. How to Transfer Files From Linux to Windows Using FTP

You can also use a file transfer protocol (FTP) application with SSH support. Transferring files via SFTP in a mouse-driven user interface is arguably easier than relying on typed commands.

Again, an SSH server must be running on the Linux machine before you start. You should also ensure you have installed an FTP app on Windows, like FileZilla, which has SFTP support.

Download: FileZilla

To use this method, run FileZilla, then:

  1. Open File > Site Manager
  2. Create a New Site
  3. Set the Protocol to SFTP
  4. Add the target IP address in Host
  5. Specify a username and password
  6. Set the Logon Type to Normal
  7. Click Connect when ready
Share files between Linux and Windows using FTP

You can then use the FTP app to move files from Windows to Linux and back using drag and drop.

Another option you should consider is a file-syncing program. These are typically cross-platform and use an encrypted key to manage the connection between devices.

All you need to do is install the app, nominate a sync folder, then create the key. Set this up on the second PC, and your data will then sync. Two good options are available for this:

  1. Resilio Sync: Formerly known as BitTorrent Sync, Resilio is available on almost any platform you can think of. There is a paid version, but the free option is enough for syncing two devices
  2. Syncthing: For Linux, Windows, macOS, and Android, this Resilio Sync alternative offers a similar feature without the paid component

4. How to Transfer Files From Windows to a Linux Virtual Machine

Instead of running a separate PC, it’s common to run Linux or Windows in a virtual machine (VM). But is there a way to transfer files between Windows and Linux when one is installed in a VM?

Fortunately, yes. With VirtualBox, you can create a virtual shared directory for data syncing.

If you’re running Windows in a VM on Linux (or vice versa), VirtualBox is already set up for sharing. Ensure you have the Guest Additions installed on your virtual machine before proceeding.

In the VirtualBox manager, select the VM, then:

  1. Choose Start > Headless Start (or with the VM running, Devices > Shared Folders)

    Enable a headless start for your VM

  2. Once running, right-click the VM and select Settings > Shared Folders
  3. Select Machine Folders
  4. Click the + symbol on the right (or right-click and select Add Shared Folder)
  5. Browse the Folder Path and find the directory you want to use
  6. Set a name (if necessary), then OK

    Share files between Windows and Linux in a virtual machine

  7. Use the Auto-mount checkbox to ensure the share is available whenever the VM runs
  8. Click OK again to confirm and exit

When you reboot the VM, the share will be ready to swap data between the host PC and the guest operating system.

There is another option for sharing files between Windows and Linux PCs. However, creating a shared file on one or both systems and then accessing it across a network is unreliable at best.

Sharing Files Between Windows and Linux Is Easy

Whether you’re new to Linux or you find Windows unfamiliar, sharing data between them is easier than you think. Now that you know how to transfer files from Windows to Linux and vice versa, we’d recommend you try all the methods we’ve mentioned above and work out which one you’re most comfortable with.

If you’re syncing data to Linux, there’s a good chance you’re switching from Windows. Don’t worry—it’s easier than you think.

Transferring Files from Windows to Linux Using Rsync and SSH

This guide has everything you need to successfully transfer files from Windows to Linux with Rsync and SSH. Rsync is a reliable tool for file synchronization, and when combined with SSH, it ensures secure file transfers between systems. In this step-by-step guide, we’ll show you how to set up Rsync and SSH on your Windows computer and Linux server, making file transfers effortless.

Setting up SSH on both Windows and Linux systems

Let’s start by setting up SSH on both your Windows and Linux environments.

For Windows, you can use the built-in OpenSSH client, which was introduced in Windows 10 version 1809 and later. To enable the OpenSSH client, open the Windows PowerShell or Command Prompt and run the following command:

Get-WindowsCapability -Online | Where-Object {$_.Name -like 'OpenSSH.Client*'} | Add-WindowsCapability -Online

This command will install the OpenSSH client on your Windows system.

enable open ssh in windows by executing the command mentioned in this blog in the powershell

Once the installation is complete, you can test the SSH connection by running the following command:

 ssh user@remote_linux_server

Replace user with the username you use to log in to your Linux server, and remote_linux_server with the IP address or hostname of your Linux server.

You can check the connectivity from windows machine to linux server using this command mentioned in the blog.

On the Linux side, SSH is typically pre-installed, but you may need to ensure that the SSH server (sshd) is running. Open a terminal on your Linux system and run the following command to check SSH is available or not:

ssh -V

If this command shows an output, it means the SSH is installed on the machine. If not install OpenSSH and also make sure to check the status of the SSH on your machine before going to the next steps.
Refer to this article: How to install and use SSH on Linux for OpenSSH installation and checking status of it.

use ssh -V command to check the presence of OpenSSH installation on your machine

Now that you have SSH set up on both your Windows and Linux systems, you’re ready to move on to the next step.

Installing and configuring Rsync on Windows and Linux

Rsync is a powerful file synchronization tool that can be used in combination with SSH to efficiently transfer files between Windows and Linux systems. Let’s start by installing Rsync on your Windows computer.

For Windows, you can download and install the Cygwin tool, which includes the Rsync utility. Visit the Cygwin website (https://www.cygwin.com/) and download the Cygwin installer. During the installation process, make sure to select the “Rsync” package from the list of available packages.

Installation tutorial for installing cygwin for rsync utility in windows

Alternatively, you can use the WinSCP application, which includes a built-in Rsync implementation. Visit the WinSCP website (https://winscp.net/eng/index.php) and download the latest version of the software.

On the Linux side, Rsync is typically pre-installed, but you can install it using your distribution’s package manager. For example, on Ubuntu or Debian-based systems, you can run the following command:

sudo apt-get update 
sudo apt-get install rsync

Once Rsync is installed on both your Windows and Linux systems, you can configure it to work seamlessly with SSH.

Also, you’ll need to ensure that the SSH server is set up to allow Rsync connections in the Linux machine. You can do this by editing the SSH server configuration file, typically located at /etc/ssh/sshd_config. Look for the line that says Subsystem sftp /usr/lib/openssh/sftp-server and uncomment it (remove the “ at the beginning of the line).

vi /etc/ssh/sshd_config

Save the configuration file and restart the SSH service using the following command:

sudo systemctl restart ssh

The command to restart the SSH service can differ based on the Linux distribution you’re using. It’s essential to use the appropriate command that corresponds to the OpenSSH version installed on your machine to ensure a smooth and successful restart.

To enable rsync uncomment the line mentioned in the blog in the ssh configuration file.

With Rsync and SSH set up on both your Windows and Linux systems, you’re now ready to start transferring files between the two environments.

Experience the Power of Veeble VPS Hosting

Experience the power of Veeble VPS hosting. Our plans are affordable, reliable, and packed with features that will help you take your business to the next level.

Choose Your Plan

Transferring files from Windows to Linux using Rsync and SSH

Now that you have Rsync and SSH configured on both your Windows and Linux systems, let’s explore how to use them to transfer files from your Windows computer to your Linux server.

Open a Command Prompt or PowerShell window on your Windows computer and navigate to the directory containing the files you want to transfer. Then, use the following Rsync command to copy the files to your Linux server:

rsync -avzc --delete -e "ssh" /path/to/local/files user@remote_linux_server:/path/to/remote/destination
Transferring files from Windows to Linux using Rsync and SSH with the help of Cygwin software

When using rsync in Cygwin, you need to reference Windows directories through the /cygdrive mount point. For example, if your folder to sync is located in the Downloads directory of your user profile, the path would be something like /cygdrive/c/Users/your_username/Downloads/<your folder>.

Here’s what each part of the command does:

  • rsync: Invokes the Rsync utility.
  • -avzc: Enables the following options:
  • -a: Preserves file attributes and permissions.
  • -v: Enables verbose mode, providing more detailed output.
  • -z: Compresses the data during transfer to reduce the amount of data sent.
  • -c: Checks the file checksums to ensure data integrity.
  • --delete: Deletes any files on the remote server that are not present in the local directory.
  • -e "ssh": Specifies that the transfer should be done over an SSH connection.
  • /path/to/local/files: The path to the local files or directory you want to transfer.
  • user@remote_linux_server:/path/to/remote/destination: The SSH username and the path to the remote destination on your Linux server.

Replace the placeholders in the command with the appropriate values for your setup.

The first time you run this command, it will prompt you to accept the host key of the remote Linux server. Once you’ve accepted the host key, the transfer will begin, and you’ll see the progress displayed in the console.

If you need to transfer files regularly, you can create a batch file or a PowerShell script to automate the process. This will save you time and ensure that the file transfers are consistent and reliable.

Troubleshooting common issues during file transfer

While Rsync and SSH generally provide a seamless file transfer experience, you may occasionally encounter some issues. Let’s explore some common problems and their solutions.

  1. SSH connection refused: If you encounter an error message indicating that the SSH connection was refused, it’s likely that the SSH server on your Linux system is not running or is not accessible. Please refer to the article: Troubleshooting “SSH Connection Refused” Error and Regaining Access to resolve it.
  2. Permission denied: If you receive a “Permission denied” error during the file transfer, it means that the user account you’re using on the Linux server does not have the necessary permissions to access the destination directory. You can either log in as a user with higher privileges or change the permissions of the destination directory using the sudo chmod command.
    Reference: Managing File Ownership and Group Ownership in Linux
  3. Checksum mismatch: Rsync uses checksums to ensure data integrity during the transfer process. If you encounter a checksum mismatch error, it could be due to a network issue or a problem with the source files. Try running the Rsync command with the --checksum option to perform a more thorough checksum verification.
  4. Insufficient disk space: If the transfer fails due to insufficient disk space on the remote Linux server, you’ll need to free up some space or transfer the files to a different location with more available storage.
  5. Firewall or network issues: If the transfer is slow or intermittent, it could be due to firewall or network-related issues. Ensure that the necessary ports (typically 22 for SSH) are open and accessible between your Windows computer and the Linux server.

To troubleshoot these issues, you can try the following steps:

  • Check the SSH server logs on the Linux system for any error messages.
  • Verify the user permissions and directory access on the Linux server.
  • Run the Rsync command with additional verbose options (-vvv) to get more detailed output.
  • Test the network connectivity between your Windows computer and the Linux server using tools like ping or telnet.
  • Temporarily disable any firewalls or antivirus software that might be interfering with the file transfer.

By addressing these common issues, you can ensure a smooth and reliable file transfer process between your Windows and Linux systems.

Best practices for efficient file transfer between Windows and Linux

To get the most out of your file transfers using Rsync and SSH, consider the following best practices:

  1. Use compression: Enabling the -z option in the Rsync command compresses the data during the transfer process, which can significantly reduce the amount of data sent over the network, especially for large files or directories.
  2. Exclude unnecessary files: Use the --exclude option in the Rsync command to exclude files or directories that you don’t need to transfer, such as temporary files, log files, or hidden system files. This can help speed up the transfer process and reduce the amount of data transferred.
    Refer: Optimizing Rsync: Ignore Unwanted Files and Directories
  3. Maintain a consistent file structure: Try to keep the file structure and directory hierarchy the same on both the Windows and Linux systems. This will make it easier to manage and locate files after the transfer is complete.
  4. Use relative paths: When specifying the source and destination paths in the Rsync command, use relative paths instead of absolute paths. This will make the command more portable and easier to use in different scenarios.
  5. Automate the transfer process: Create a batch file or a PowerShell script to automate the Rsync command, making it easy to run the file transfer regularly or as needed.
  6. Monitor the transfer progress: Use the verbose options (-vvv) in the Rsync command to get detailed output on the transfer progress, file sizes, and any errors that may occur. This will help you troubleshoot issues more effectively.
  7. Leverage incremental backups: Rsync is particularly useful for performing incremental backups, where it only transfers the files that have changed since the last backup. This can save a significant amount of time and bandwidth, especially for large data sets.
  8. Consider using a graphical tool: While the command-line Rsync approach is powerful, you may also want to explore graphical tools like WinSCP or FileZilla, which provide a user-friendly interface for managing file transfers between Windows and Linux.
  9. Secure the SSH connection: Ensure that the SSH connection is secure by using strong passwords or SSH keys for authentication. Avoid using weak or default passwords, and consider implementing two-factor authentication for added security.
  10. Monitor disk space on the Linux server: Keep an eye on the available disk space on the Linux server to ensure that there is enough room to accommodate the transferred files. Set up alerts or monitoring tools to notify you when disk space is running low.

By following these best practices, you can streamline the file transfer process, improve efficiency, and maintain the security and integrity of your data during the transfer between your Windows and Linux systems.

Alternatives to Rsync and SSH for file transfer

While Rsync and SSH are a powerful combination for transferring files between Windows and Linux, there are alternative tools and methods you can consider:

  1. FTP/FTPS/SFTP: File Transfer Protocol (FTP) and its secure variants, FTPS (FTP over SSL/TLS) and SFTP (SSH File Transfer Protocol), are widely used for file transfers. These protocols can be used with various FTP client applications, such as FileZilla or WinSCP, to transfer files between Windows and Linux systems.
  2. Cloud storage services: Services like Dropbox, Google Drive, or Microsoft OneDrive provide a convenient way to transfer files between Windows and Linux systems. Simply upload the files to the cloud storage, and then download them on the other system.
  3. Network file sharing: You can set up network file sharing between your Windows and Linux systems using protocols like SMB (Server Message Block) or NFS (Network File System). This allows you to access and transfer files directly between the two systems over the network.
  4. Web-based file transfer tools: There are various web-based file transfer tools, such as WeTransfer or Sendspace, that you can use to transfer files between your Windows and Linux systems. These tools typically provide a simple and user-friendly interface for uploading and downloading files.
  5. Portable storage devices: If you have a portable storage device, such as a USB flash drive or an external hard drive, you can use it to physically transfer files between your Windows and Linux systems.

Each of these alternatives has its advantages and disadvantages, and the choice will depend on your specific requirements, such as the size of the files, the frequency of transfers, and the level of security needed.

For example, FTP/FTPS/SFTP may be a good option if you need to transfer files regularly, but they may not provide the same level of security as Rsync and SSH. Cloud storage services can be convenient, but they may not be suitable for transferring sensitive or large files. Network file sharing can be efficient, but it may require additional configuration and setup.

When choosing an alternative method, consider factors such as ease of use, transfer speed, security, and compatibility with your Windows and Linux systems. Evaluate the trade-offs and select the solution that best fits your needs.

By following these guidelines, you’ll be able to seamlessly transfer files between your Windows computer and Linux server, whether you need to perform regular backups, share important documents, or synchronize project files. The combination of Rsync and SSH provides a robust and secure solution for your file transfer needs.

Scale Without Limits

Adapt to changing demands with flexible and scalable solutions. Grow your business seamlessly.

Choose Your Plan

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Оптимизация работы ssd под windows 10
  • Программы для работы игр для windows 10
  • Windows network data usage monitoring driver
  • Диспетчер серверов windows server 2019 настройка
  • Options error on windows ifconfig is required when dev tun is used