Using the Windows Subsystem for Linux (WSL) is great, until you forget the exact wsl command you need. Then you end up searching docs, clicking around, and losing focus.
This guide collects the most useful basic WSL commands in one place so you can install, manage, and debug your Linux distributions on Windows without drama.
If you work in software development, DevOps, or any backend-heavy industry, these WSL commands will help you get a more stable, faster, and easier-to-control workflow on your Windows machine.
When you’re on a fresh Windows machine and just want “Linux, now”, start here:
bash
wsl --install
What it does:
Installs WSL
Installs a default Linux distribution (usually Ubuntu)
Sets up the basics so you can run Linux commands from Windows
If you want a specific distribution from the start:
bash
wsl --install
For example:
bash
wsl --install Debian
Useful options when running wsl --install:
--distribution <Name> – install a specific Linux distribution.
--no-launch – install, but don’t open the distro right away.
--web-download – install from an online source instead of the Microsoft Store.
When WSL is not installed yet, you also have some extra switches:
--inbox – install WSL via Windows components instead of the Store.
--enable-wsl1 – enable WSL 1 support during install.
--no-distribution – install the WSL platform, but no Linux distro yet.
On some older Windows 10 builds, you may need:
bash
wsl --install -d
Same thing, just more explicit.
Once you’ve installed WSL, you’ll usually want to know:
What can I install?
What did I already install?
What’s running right now?
bash
wsl --list --online
Short form:
bash
wsl -l -o
This shows all Linux distributions available online for WSL.
bash
wsl --list --verbose
Short form:
bash
wsl -l -v
You’ll see:
Name of each installed distro
Whether it’s Running or Stopped
Which version it uses: WSL 1 or WSL 2
Extra filters:
--all – show all distros
--running – show only running ones
--quiet – show only names (no extra info)
WSL has two main versions:
WSL 1 – simpler architecture, closer to the old days, sometimes better for Windows file performance
WSL 2 – real Linux kernel in a lightweight VM, usually better compatibility and performance for Linux tools
bash
wsl --set-version
Example:
bash
wsl --set-version Ubuntu 2
That will convert Ubuntu to WSL 2.
Note: Switching between WSL 1 and WSL 2 can be slow, especially for big projects. Always back up important files before converting.
bash
wsl --set-default-version
Example:
bash
wsl --set-default-version 2
From now on, any newly installed distro will use that version by default.
If you type just wsl with no arguments, Windows will use your default distro. To set it:
bash
wsl --set-default
Example:
bash
wsl --set-default Ubuntu
Now wsl will drop you into Ubuntu.
From PowerShell or CMD:
bash
wsl ~
That ~ means “user home”.
Inside a WSL shell, you can always jump back home with:
bash
cd ~
bash
wsl --distribution --user
Example:
bash
wsl --distribution Debian --user root
If the user doesn’t exist inside that distro, WSL will complain. You can check the current user with:
bash
whoami
bash
wsl --user
This uses your default distro, but switches to the user you specify.
This part is easy to forget and then you end up logging in as root forever.
Run from Windows (PowerShell or CMD):
bash
config --default-user
Example:
bash
ubuntu config --default-user johndoe
Next time Ubuntu launches, it logs in as johndoe by default.
If you forgot the distro name, you can always check:
bash
wsl -l
Note: This config --default-user method doesn’t work for imported distributions (those created from .tar or .vhdx). For those, you need to edit /etc/wsl.conf inside the distro.
You don’t want to debug bugs that were already fixed months ago, so keep WSL itself updated.
bash
wsl --update
This pulls the latest WSL version available for your system.
Option:
--web-download – download the latest update directly from the web instead of using the Store.
bash
wsl --status
This shows:
Default WSL version (1 or 2)
Default distribution
Kernel version and other basics
bash
wsl --version
This prints version information about WSL and its components, useful when you’re debugging or working with support.
bash
wsl --help
This shows the full list of commands and options supported by your installed WSL version.
Sometimes WSL gets stuck, or you tweak settings and need a clean restart.
bash
wsl --shutdown
This stops:
All running WSL distributions
The lightweight WSL 2 utility VM
Use this after changing memory or CPU limits in .wslconfig, or when something feels “off” and you want a clean reset.
bash
wsl --terminate
Example:
bash
wsl --terminate Ubuntu
This stops only that distro, without touching others.
If you run services inside WSL and want to reach them from Windows or from outside, IP details matter.
Useful commands:
Inside WSL, to get the WSL 2 VM IP:
bash
wsl hostname -I
Inside WSL, to get the Windows host IP (from WSL’s point of view):
bash
ip route show | grep -i default | awk '{ print $3 }'
Use these when you’re exposing web apps, APIs, or databases to and from the WSL environment.
If you’re building something more serious—like a backend that will eventually live on real servers—you’ll probably want to test the same stack on remote hardware too. That’s where dedicated hosting comes in handy, especially when it matches your Linux + WSL workflow.
👉 See how GTHost instant dedicated servers pair smoothly with WSL-based development and testing
Then you can develop on WSL locally, and push the same tools and scripts to a remote machine that behaves very much like your local Linux environment.
If you have a “golden” WSL environment or a project setup you never want to lose, you can export it.
bash
wsl --export
This saves a snapshot of the distro into a file (tar by default).
Example:
bash
wsl --export Ubuntu ubuntu-backup.tar
Options:
--vhd – export as a .vhdx virtual disk instead of a .tar (WSL 2 only).
You can take an exported distro and import it as a new one.
bash
wsl --import
Example:
bash
wsl --import Ubuntu-Dev D:\WSL\Ubuntu-Dev ubuntu-backup.tar
Options:
--vhd – import from a .vhdx file instead of a tar.
--version 1 or --version 2 – control whether the new distro uses WSL 1 or WSL 2.
If you have a .vhdx file formatted as ext4 and want to use it directly:
bash
wsl --import-in-place
The .vhdx becomes a new WSL distribution.
If a Linux distro becomes a mess or you simply don’t need it anymore, you can reset or remove it.
To unregister (and effectively uninstall) a distro:
bash
wsl --unregister
Example:
bash
wsl --unregister Ubuntu
Important:
This deletes everything inside that distro:
Files
Settings
Installed packages
After this, it’s gone. Installing Ubuntu again will give you a clean, fresh environment.
You can also remove the distribution app from Windows like any other installed app and then reinstall it later from the Store if you want.
Sometimes you need WSL to see a physical disk, a USB drive, or a virtual disk directly.
bash
wsl --mount
This attaches and mounts a physical disk in all WSL 2 distributions. Replace <DiskPath> with the actual device path.
Common options:
--vhd – treat <DiskPath> as a virtual hard disk.
--name <Name> – use a custom name for the mount point.
--bare – attach the disk but don’t mount it yet.
--type <Filesystem> – specify filesystem type (defaults to ext4).
--partition <Number> – mount a specific partition; otherwise, it uses the whole disk.
--options <MountOptions> – pass filesystem-specific options (like certain ext4 options).
Example of detecting filesystem type inside WSL:
bash
blkid /dev/sdb1
bash
wsl --unmount
If you don’t specify a disk path, WSL will unmount and detach all mounted disks.
You might still see these in old blog posts or Stack Overflow answers:
bash
wslconfig.exe [Argument] [Options]
bash [Options]
lxrun /[Argument]
They belong to the early days of WSL. Now, you should use the wsl (or wsl.exe) command instead. If you’re writing scripts today, stick to wsl commands so your setup stays current.
You don’t need to memorize every switch and flag to get real work done with the Windows Subsystem for Linux. With these core WSL commands, you can install, inspect, tweak, back up, and reset your Linux environments on Windows in a way that’s faster, more stable, and much easier to control.
And when your local WSL workflow grows into something that needs real servers—CI runners, staging environments, or production-like boxes—that’s where hosting choices matter. 👉 This is exactly why GTHost is suitable for WSL-based development and backend testing scenarios: you get instant dedicated servers that behave like real Linux machines while staying easy to pair with your WSL setup.