Introduction
Microsoft Windows 11 includes a new feature called Windows Subsystem for Linux (WSL), which allows users to run a GNU/Linux environment directly on Windows. This integration enables users to utilize popular Linux tools, such as rsync, right on their Windows machines. This article will guide you through installing WSL, setting up a Debian environment, and configuring rsync to behave like its Linux counterpart.
Installing Windows Subsystem for Linux (WSL)
To install WSL, follow these steps:
- Press
Win + Xand select Windows PowerShell (Admin). - Execute the following command to enable the WSL optional component:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - To enable the optional Linux kernel update package, execute the following command:
wsl --install - Restart your computer.
Setting Up a Debian Environment
After installing WSL, you can set up a Debian environment with the following steps:
- Press
Win + Sand search for Microsoft Store. - Search for "Debian" in the Microsoft Store and click Get to install it.
- After the installation, launch Debian by searching for it in the start menu.
- You will be prompted to create a UNIX user account and password. Follow the on-screen instructions to complete the setup.
Configuring rsync on Windows 11
Once the Debian environment is set up, you can configure rsync to behave like its Linux counterpart. First, ensure that rsync is installed on both your local Windows 11 machine and the remote Linux server.
Next, you can create a batch script on your Windows 11 machine to run rsync with the appropriate options. The following example demonstrates how to create a batch script to sync a local directory with a remote server using rsync:
Example Batch Script
@echo off
setlocal
set RSYNC=C:\WSL$\Debian\usr\bin\rsync.exe
set SOURCE_DIR=C:\path\to\local\directory
set REMOTE_USER=your_remote_username
set REMOTE_HOST=your_remote_hostname_or_ip
set REMOTE_DIR=/path/to/remote/directory
set OPTIONS=--archive --verbose --compress --rsh="ssh -p 22"
%RSYNC% %OPTIONS% %SOURCE_DIR% %REMOTE_USER%@%REMOTE_HOST%:%REMOTE_DIR%
endlocal
Replace the appropriate values in the provided example with the correct paths, usernames, and hostnames. Save the script as a .bat file and run it to synchronize the directories.
To get Windows 11 rsync to behave like Linux (Debian), follow these steps:
- Install Windows Subsystem for Linux (WSL).
- Set up a Debian environment.
- Configure
rsyncusing a batch script with the appropriate options.
References
- Microsoft Documentation - Installing Windows Subsystem for Linux
- Debian Wiki - Rsync