---
title: Windows Subsystem for Linux
kind: note
description: light-weight integrated VM
words: 76
readingMinutes: 1
created: '2024-07-23T00:00:00.000Z'
updated: '2026-06-29T20:34:03+02:00'
website: https://learn.microsoft.com/en-us/windows/wsl/
---
## Link

<https://learn.microsoft.com/en-us/windows/wsl/>

## FAQ
### Get the size of WSL distribution disks
1. Get the name of the distribution:
	```powershell
	wsl --list
	```
1. Insert it in the following command to get the filename:
	```powershell
	(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '<distribution-name>' }).GetValue("BasePath") + "\ext4.vhdx"
	```
1. Check the filesize using [PowerShell](/notes/microsoft-powershell) or [Windows](/notes/microsoft-windows) Explorer.
### Using the Windows OpenSSH Agent from WSL
1. Install `socat` in the WSL distro:
  ```sh
  sudo apt install socat
  ```
1. Install `npiperelay` in Windows:
  ```powershell
  choco install npiperelay
  ```
1. Insert into `~/.bashrc` in the WSL distro:
  ```shell
  # Configure ssh forwarding
  export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
  # need `ps -ww` to get non-truncated command for matching
  # use square brackets to generate a regex match for the process we want but that doesn't match the grep command running it!
  ALREADY_RUNNING=$(ps -auxww | grep -q "[n]piperelay.exe -ei -s //./pipe/openssh-ssh-agent"; echo $?)
  if [[ $ALREADY_RUNNING != "0" ]]; then
      if [[ -S $SSH_AUTH_SOCK ]]; then
          # not expecting the socket to exist as the forwarding command isn't running (http://www.tldp.org/LDP/abs/html/fto.html)
          echo "removing previous socket..."
          rm $SSH_AUTH_SOCK
      fi
      echo "Starting SSH-Agent relay..."
      # setsid to force new session to keep running
      # set socat to listen on $SSH_AUTH_SOCK and forward to npiperelay which then forwards to openssh-ssh-agent on windows
      (setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork &) >/dev/null 2>&1
  fi
  ```
Source: <https://stuartleeks.com/posts/wsl-ssh-key-forward-to-windows/>
### Enabling systemd in WSL2
- Edit `/etc/wsl.conf` as root:
	```text /etc/wsl.conf
	[boot]
	systemd=true
	```
	- Source: [Systemd support is now available in WSL!](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/#set-the-systemd-flag-set-in-your-wsl-distro-settings)
