The WSL Onion

Calling powershell.exe from PowerShell inside WSL

The other day I was playing around in WSL with a colleague of mine and we did this: # We start out in WSL Debian and enter PowerShell Core marco@box:~$ pwsh PowerShell 7.2.2 Copyright (c) Microsoft Corporation. Type 'help' to get help. # Then we get the major version of the active PowerShell session PS /home/marco> ($PSVersionTable.PSVersion).Major 7 # Then we call powershell.exe and get a completely different version! [Read More]

Windows Subsystem For Linux 2: Debian+Podman

The problem: Docker itself can’t be run in WSL2 as it requires the docker daemon, usually run though sysemd. The solution: Podman works just fine and can easilly be installed, allthough we will need to configure some things to make it work properly. Install Podman The official installation instructions are a great place to find out how to install on your distro. On my Debian 11 (bullseye) system I used apt: sudo apt install podman [Read More]

Hidden WSL Fileshare

WSL file systems get exposed as a hidden share network share: \\wsl$\<WSL Name>\<path\to\file>

For example, my Debian home folder is at: \\wsl$\Debian\home\kamner

wsl  windows 

Windows Terminal: Open New WSL Tab In Linux Home Folder

The path you are in when opening a new WSL tab is determined by startingDirectory. This parameter needs to be a valid Windows path, which isn’t great if we want to end up in /home/kamner inside WSL. The nice thing about WSL is that it will resolve windows paths into their equivalent WSL/linux path if possible. For example, C:\Scripts would resolve to /mnt/c/Scripts. Using this and the neat trick that the WSL filesystem is exposed as a a hidden fileshare ([[technology/windows/wsl-hidden-fileshare]]) we can get to where we want. [Read More]