access_time 6 months ago languageEnglish

Windows Subsystem for Linux CLIs

visibility 40 comment 0

List distros

wsl -l

Example output:

Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)

In the above output default distro is Ubuntu-18.04.

Shutdown running distro

wsl --shutdown

The above command immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.

Terminate the specified distro

wsl --terminate {distro}

Set default distro

wsl --set-default, -s <Distro>

For example, the following command set the default distro to Debian.

wsl -s Debian

Run the specified distro

Use the following command to run the specified distro:

wsl --distribution, -d <Distro>

For example, the following command runs Debian distro:

wsl -d Debian

For other commands

Run help command to learn all other available commands.

wsl --help
Copyright (c) Microsoft Corporation. All rights reserved.

Usage: wsl.exe [Argument] [Options...] [CommandLine]

Arguments for running Linux binaries:

    If no command line is provided, wsl.exe launches the default shell.

    --exec, -e <CommandLine>
        Execute the specified command without using the default Linux shell.

        Pass the remaining command line as is.

    --distribution, -d <Distro>
        Run the specified distribution.

    --user, -u <UserName>
        Run as the specified user.

Arguments for managing Windows Subsystem for Linux:

    --export <Distro> <FileName>
        Exports the distribution to a tar file.
        The filename can be - for standard output.

    --import <Distro> <InstallLocation> <FileName> [Options]
        Imports the specified tar file as a new distribution.
        The filename can be - for standard input.

            --version <Version>
                Specifies the version to use for the new distribution.

    --list, -l [Options]
        Lists distributions.

                List all distributions, including distributions that are currently
                being installed or uninstalled.

                List only distributions that are currently running.

            --quiet, -q
                Only show distribution names.

            --verbose, -v
                Show detailed information about all distributions.

    --set-default, -s <Distro>
        Sets the distribution as the default.

    --set-default-version <Version>
        Changes the default install version for new distributions.

    --set-version <Distro> <Version>
        Changes the version of the specified distribution.

        Immediately terminates all running distributions and the WSL 2 lightweight utility virtual machine.

    --terminate, -t <Distro>
        Terminates the specified distribution.

    --unregister <Distro>
        Unregisters the distribution.

        Display usage information.
copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn.

Want to contribute on Kontext to help others?

Learn more

More from Kontext

visibility 166
thumb_up 1
access_time 6 months ago
visibility 244
thumb_up 0
access_time 6 months ago