I needed Subversion client access on a fresh Windows 10 installation. Rather than installing one of the Subversion clients for Windows (for example, CollabNet Subversion or SlikSVN), I decided to take advantage of the new WSL (Windows Subsystem for Linux).
The best part of macOS is the Linux system which macOS runs on. And now, the latest Windows 10 has something equivalent. Below are the steps I took to install WSL (Ubuntu flavor) and Subversion.
Install WSL Ubuntu
- Enable the WSL feature.
- Run “Turn Windows features on or off” and check the box for the “Windows Subsystem for Linux” feature.
- Alternatively, launch the Windows PowerShell as an administrator and run this command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
- Restart the computer to finish enabling the WSL feature.
- Launch the “Windows Store” and search for “Run Linux on Windows”.
- Click on Ubuntu (or your favorite flavor of Linux).
- Click on Get (or Install) to install Ubuntu.
- Run the installed “Ubuntu” app to configure the WSL.
- After several minutes, it will prompt you to input a Unix username and password for your default sudo user. (This will be the default user that your bash shell runs under.)
- You can run “Ubuntu” or “bash” to launch the bash terminal shell.
- “Ubuntu” will put you in the “/home/<username>” directory.
- “bash” will keep the current directory.
- Some Linux commands to try out:
# Show version of Linux
lsb_release -a
# Show HOME variable and current directory
echo $HOME
pwd
# Two ways to list the contents of the "C:\Program Files" directory
ls "/mnt/c/Program Files"
ls /mnt/c/Program\ Files
# Log into root user
sudo su
While it is easy to access the Windows drive from Ubuntu by using “/mnt/c” for the C:\ drive, the Linux root “/” directory maps to the Windows directory at “C:\Users\<username>\AppData\Local
\Packages\CanonicalGroupLimited.UbuntuonWindows_<UID>\LocalState\rootfs”.
I recommend creating a NTFS symbolic link to make it easier to access the Linux home directory. Open a Command Prompt as administrator and run this command:
Note: Strangely, if I create a new file in the Ubuntu’s rootfs directory using Windows, the file is not visible under the Ubuntu shell. Editing an existing file from Windows works fine.
Install Subversion
Installing Subversion on WSL Ubuntu is identical to installing Subversion on my unmanaged Ubuntu virtual server (see Subversion Over SSH on an Unmanaged VPS).
Note: You may notice the switch from the “apt-get” command to the “apt” command when installing and updating Ubuntu packages. The “apt” command is a slightly smaller subset of the “apt-get” command, more user-friendly, and appears to be the recommended command to use going forward.
Below are the steps I took to update Ubuntu, install Subversion, and connect to the remote Subversion repository on my server.
- Update Ubuntu packages using the bash shell:
# Refresh the APT repository index
# If you don't update, the install command below will fail.
sudo apt update
# List packages that can be upgraded
apt list --upgradable
# Upgrade packages with auto-handling of dependencies
# (same as "apt-get dist-upgrade")
sudo apt full-upgrade
# Remove dependencies which are no longer used (frees up space)
sudo apt autoremove - Install Subversion:
# Install subversion
sudo apt install subversion
# Check that subversion is installed
svn --version - Because my server uses a custom SSH port and requires the Subversion client to use the SVN+SSH protocol, we must configure SSH to use the custom port automatically because there is no option to input the custom port on the command line.
# Create .ssh configuration directory under the home directory
mkdir ~/.ssh
# Optionally, restrict access to the directory to just the user/owner
chmod 700 ~/.ssh
# Create SSH config file
cat > ~/.ssh/config
Host mydomain.com
Port 3333
PreferredAuthentications publickey,password
# Press CTRL-D to save and exit the file
# SSH requires that only the user has access to files under the ~/.ssh directory.
# If you don't restrict, SSH will throw a "Bad owner or permissions" warning and ignore the files.
chmod 600 ~/.ssh/config
# Copy the trusted client "id_rsa" and "id_rsa.pub" identity files to the ~/.ssh directory
# to eliminate the need to input the password when using SSH. - Connect to the remote Subversion repository:
# List all projects in the remote repository.
svn list svn+ssh://mynewuser@mydomain.com/var/repos
# Check out a local, working copy of the project from the repository
svn co svn+ssh://mynewuser@mydomain.com/var/repos/myproject ./myproject
# View the working copy's info (no need to input the svn+ssh URL once inside the project)
cd ./myproject
svn info
See my followup post, Install LEMP on Ubuntu WSL on Windows 10, for instructions on getting a full LEMP (Linux, Nginx, MySQL, PHP) development environment working on Ubuntu WSL.
Info above derived from: