- Blog
- /
- WSLInterop
WSL Interop
The Windows Subsystem for Linux (WSL) is a compatibility layer for running GNU/Linux binary executables natively on Windows 10 and above and Windows Server 2019 and above. It supports running most command-line tools, utilities, and applications unmodified, without the overhead of a traditional virtual machine or dualboot setup. You can install many GNU/Linux distributions ontop of the subsystem kernel. In this article we will be using Ubuntu.
Installing/Enabling WSL and Ubunti
You can now install WSL with an Ubuntu disribution from a single command.
From PowerShell running as administrator, run:
wsl --install -d Ubuntu
You'll need to restart after the install command has complete. Once started back up, launch Ubuntu and configure your user details.
Then, in the terminal run the following commands to make sure everything is up to date.
sudo apt update
sudo apt upgrade
Configure to use WSL 2
WSL 2 should already be the default on new istallations, so should be set to 2 already. However the following Powershell commands can be used to determine the selected version / distro and modify them accordingly if nessesary.
To view a list of installed distros and the version of WSL they are running:
wsl -l -v
To set the default wsl version 2:
wsl --set-default-version 2
To select Ubuntu as the default distro:
wsl --set-default Ubuntu
Finally, to modify the Ubunti distro to use WSL 2:
wsl --set-version Ubuntu 2
WSL Interop
Its useful to expose some of the commands such as grep to the Powershell console in Windows. This saves you the time switching between shells.
Open a Powershell windows and run the following:
Install-Module WslInterop -Scope CurrentUser -Force
Then open your powershell profile.
code $profile
Add the following lines
Import-WslCommand grep
Import-WslCommand ssh
Import-WslCommand ssh-keygen
Import-WslCommand curl
Import-WslCommand vi
Import-WslCommand openssl
Tags:
About the author:
I am a senior software engineering and technical leader / Microsoft technologies technical architect, with a strong passion for continuous delivery. I am a firm believer in empowered teams with true DevOps cultures. I encourage responsibility over role, high quality and full stack engineers, showing ownership of the software and its behaviour, end to end, from requirements maturing all the way through to its continual and successful running in Production.