Skip to content

Windows Subsystem for Linux (WSL) CLI Cheat Sheet

Basic Commands

Installation

Open PowerShell in administrator mode by right-clicking and selecting "Run as administrator", enter the wsl --install command, then restart your machine

wsl --install

List available Linux distributions

See a list of the Linux distributions available through the online store

wsl --list --online

List installed Linux distributions

List your installed Linux distributions, including state and the version of WSL running the distribution

wsl --list --verbose

List only distributions that are currently running

wsl --list --running

Change the default Linux distribution installed

To change the distribution installed, enter:

wsl --install <Distro>

Replace with the name of the distribution you would like to install.

Run a specific WSL distribution

To run a specific wsl distribution from within PowerShell without changing your default distribution, use the command:

wsl --distribution <Distro>

Set default Linux distribution

Set the default Linux distribution that WSL commands will use to run

wsl --set-default <Distro>

Update WSL

Update your WSL version to the latest version

wsl --update

Check WSL version

Check the version information about WSL and its components

wsl --version

Check WSL status

See general information about your WSL configuration

wsl --status

Shutdown

Immediately terminate all running distributions and the WSL 2 lightweigth utility virtual machine

wsl --shutdown

Terminate

Terminate a specified distribution

wsl --terminate <Distro>

Unregister or uninstall a Linux distribution

Unregister and uninstall a WSL distribution

wsl --unregister <Distro>

Import a distribution

Imports the specified tar file as a new distribution

wsl --import <Distro> <InstallLocation> <FileName>

Export a distribution

Exports a snapshot of the specified distribution as a new distribution file

wsl --export <Distro> <FileName>

Options and Help

wsl --help

Additional References


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

  2. placeholder