The Easiest Guide to Installing and Managing the Windows Subsystem for Linux (WSL)

The Windows Subsystem for Linux (WSL) is a powerful addition to Windows 10 and Windows 11. It allows you to run a full Linux distribution without the hassle of a traditional VM setup. For a lot of development tasks, it’s (almost) as good as running on bare metal.

There are two versions of WSL, there’s WSL 1 which is the classic mode most people are used to, and WSL 2 which offers a host of advancements but is more in line with traditional virtualization without the same shortcomings (it leverages Hyper-V and a full Linux kernel). WSL 2 also supports GUI applications.

This guide is going to cover both installation via the GUI, and via command line and PowerShell. This guide is only really going to cover the newer method for installing WSL for Windows 10 2004 and later for command prompt (though I have included the legacy method just in case). I will mainly include examples for Debian, but the same instructions work with other variants (Ubuntu and beyond).

GUI Install

The GUI install requires turning on a Windows feature for Windows Subsystem for Linux (and optionally Hyper-V if you want WSL 2), rebooting your machine, then installing Debian (or distro of choice) from the Microsoft Store.

Open the Windows Start menu

Click the start icon to open the start menu.

Search for “windows features” to get “Turn Windows features on or off”

Locate the “Turn Windows features on or off” option. You can search for “windows features” or similar to locate it. You can also run “optionalfeatures” directly.

An example of the Windows Features panel

Turn on “Windows Subsystem for Linux” and Hyper-V (if you want WSL 2). This will prompt you to reboot your machine to apply the changes. This may take a couple minutes to properly apply everything.

Find the Microsoft Store

Navigate to the Microsoft Store after reboot. Type “Microsoft Store” from the start menu. There are command line ways to do this as well, but this is the easier method from the GUI.

Search for “debian” (or distro of choice)

Look for your distro of choice. I personally use Debian, but you can use whatever you like.

Search from the start menu for “debian” (or distro of choice) to finalize the installation and start your WSL distro

Once the distro of choice is done installing, it should add a “program” to launch the Linux container of choice. Once you open this, it will prompt you to finalize the setup. Debian will prompt you to add a new user. Other distributions do similar but may have further configuration options.

Command Line Install

The command line install is much easier with newer builds of Windows 10 (or Windows 11). There are also many other options and combinations to accomplish the same basic goals. We’re going to cover the standard workflow here, but provide some advanced options in the next section.

Open an administrative command prompt (you can use Powershell as well) and run the following:

wsl.exe --install -d debian

This will install WSL and Debian in one go. You can change “debian” for a distribution of choice. If you’d prefer to just install WSL itself (and choose the distribution later), run the following:

wsl.exe --install

This option is useful since you can also set the default version of WSL to 2 or 1 depending with the following:

wsl.exe --set-default-version [version number]

Legacy Method for Older Windows

You can use DISM to install features on older versions of Windows 10 (per Microsoft).

First, install the Windows Subsystem for Linux with the norestart flag (so we can control our reboot):

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Install virtualization options with the following (norestart so you can reboot when you want):

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Advanced Command Line Options

We covered some of the basic usage of installing WSL, but there is a lot of configurability possible with WSL.

Status and Availability

You can get a list of what is installed with:

wsl.exe --list --verbose

You can also add extra options like –running to get only running distributions.

This gets you a list of the distributions, the state, and the version, for example:

C:\Windows\system32>wsl.exe --list --verbose
  NAME      STATE           VERSION
* Debian    Running         1

You can get a list of available distributions (that are installable from the store) with the following:

wsl.exe --list --online

The status is available with:

wsl.exe --status

Versions and Updates

We talked about setting the default WSL version with:

wsl.exe --set-default-version [1 or 2 for version number]

But, you can also set the version for a specific container with:

wsl.exe --set-version [distribution] [version number]

You can also change which distribution is the default for when you run wsl.exe via:

wsl.exe --set-default [distribution]

WSL allows the WSL kernel to be updated with:

wsl.exe --update

Or rolled back with:

wsl.exe --update rollback

Commands and Management

You can run a basic command with the following:

wsl.exe -e [command]

Or, for it to ignore any other options (after the –):

wsl.exe -- [more command line]

Run the default container as a specific user with:

wsl.exe --user [user]

Run a specific container with the following:

wsl.exe -d [distribution]

You can chain this with the user:

wsl.exe -d [distribution] -u [user]

Change the distribution’s default user with:

[distribution] config --default-user [user]

This would look something like:

debian config --default-user myuser

Shutdown WSL 2 distributions with:

wsl.exe --shutdown

Terminate a specific WSL distribution with:

wsl.exe --terminate [distribution]

Remove an installed distribution with:

wsl.exe --unregister [distribution]

You can export a setup, run the following command:

wsl.exe --export [distribution] [tarball location]

This would look something like:

wsl.exe --export debian C:\bkup\debian.tar

To import, run:

wsl.exe --import [distribution name] [import location] [tarball location]

This looks like:

wsl.exe --import debian-test C:\WSL\debian-test C:\bkup\debian.tar

WSL includes multiple commands for mounting built off of this basic command:

wsl.exe –mount [options]

See the following documentation from Microsoft for the specifics of mounting.

See this for more information on some of the commands.

Image by Dariusz Robert Drewnicki from Pixabay

11 thoughts on “The Easiest Guide to Installing and Managing the Windows Subsystem for Linux (WSL)”

  1. That is very interesting, You are an overly skilled blogger.
    I’ve joined your feed and stay up for in the hunt for extra of your
    excellent post. Also, I have shared your website
    in my social networks

  2. Hello to every one, the contents existing at this web site are
    truly remarkable for people experience, well, keep up the
    good work fellows.

  3. Fantastic goods from you, man. I’ve understand your stuff previous to
    and you are just extremely excellent. I actually like what you have acquired here, certainly like what you’re
    stating and the way in which you say it. You make it
    entertaining and you still take care of to keep it wise.

    I can’t wait to read far more from you. This is really a terrific web site.

  4. What’s up everyone, it’s my first pay a quick visit at this web page, and article is
    really fruitful in favor of me, keep up posting these
    types of articles.

  5. Superb blog! Do you have any tips for aspiring
    writers? I’m planning to start my own blog soon but I’m a
    little lost on everything. Would you propose starting with a
    free platform like WordPress or go for a paid option? There are so many options
    out there that I’m totally confused .. Any recommendations?

    Bless you!

    • I personally use Bluehost because it made things easy, but there are a bunch of options. If you’re just getting started, consider how much you’re willing to spend and what the cost of your time maintaining it is. Managed hosting is probably going to be your best bet in the beginning (it’s cheap and low maintenance for everything but the blog itself), though you could always try something like Medium or vocal.media out for free, and they have the added bonus of being monetizable without needing to deal with ad networks and similar. A completely free WordPress solution might be worth it if you’re unsure where to start at all, but they tend to be slow, you’ll outgrow it fast, and/or they’re hard to move away from.

      I used to set up WordPress hosting and similar, but I went with managed hosting because running a blog is a job in itself. If you know how to set up hosting, it might be worth it in the long run, but personally I would start by having someone else maintain the infrastructure. Focus on content first (what are you writing and for who?), then consider how to make that content accessible (SEO, presentation, workflow), then how to monetize it (what are you doing besides ads?). That being said, don’t forget the third part if this is more than a hobby.

      Don’t fall into the trap of continuously configuring the site, changing out plugins, etc. continuously instead of producing content and engaging your audience assuming you want this to be financially viable. This blog is a hobby for me with some okay monetization avenues, but I’ve helped run blogs and similar with a clear-cut goal.

      Hope this helps!

  6. Hi! I just want to offer you a huge thumbs up for your great information you have
    got here on this post. I’ll be coming back to your web site for more soon.

  7. Hi, I do believe this is an excellent site. I stumbledupon it 😉 I am going to revisit yet again since I saved as a favorite it.
    Money and freedom is the best way to change, may
    you be rich and continue to help others.

  8. Hmm it seems like your site ate my first comment (it was super long) so I guess I’ll just sum
    it up what I wrote and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog blogger but I’m still new to the whole thing.
    Do you have any suggestions for newbie blog writers? I’d really appreciate it.

  9. Greetings from Los angeles! I’m bored to death at work
    so I decided to browse your website on my iphone during lunch break.

    I enjoy the knowledge you present here and can’t wait to take a look when I get home.
    I’m shocked at how fast your blog loaded on my phone ..

    I’m not even using WIFI, just 3G .. Anyways, amazing
    site!

  10. Hello, for all time i used to check blog posts here in the early hours in the dawn, because i
    love to gain knowledge of more and more.

Comments are closed.