DEV Community

Install Linux on Windows with WSL

In this blog, we are going to learn how to install Linux on Windows with WSL.

WSL:

The Windows Subsystem for Linux (WSL) lets developers install a Linux distribution (such as Ubuntu, OpenSUSE, Kali, Debian, Arch Linux, etc) and use Linux applications, utilities, and Bash command-line tools directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

Prerequisites:

You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 to use the commands below.

Install WSL command:
You can now install everything you need to run WSL with a single command. Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting “Run as administrator”, enter the wsl — install command, then restart your machine.

wsl --install
Enter fullscreen mode Exit fullscreen mode

This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux.

Image description

If you’re running an older build, or just prefer not to use the install command and would like step-by-step directions, see WSL manual installation steps for older versions.

Change the default Linux distribution installed
By default, the installed Linux distribution will be Ubuntu. This can be changed using the -d flag.

  1. To change the distribution installed, enter: wsl --install -d . Replace with the name of the distribution you would like to install.

  2. To see a list of available Linux distributions available for download through the online store, enter: wsl --list --online or wsl -l -o.

  3. To install additional Linux distributions after the initial install, you may also use the command: wsl --install -d .

Basic commands for WSL:
The WSL commands below are listed in a format supported by PowerShell or Windows Command Prompt. To run these commands from a Bash / Linux distribution command line, you must replace wsl with wsl.exe. For a full list of commands, run wsl --help.

Install:

wsl --install
Enter fullscreen mode Exit fullscreen mode

List available Linux distributions

wsl --list --online
Enter fullscreen mode Exit fullscreen mode

List installed Linux distributions

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

See a list of the Linux distributions installed on your Windows machine, including the state (whether the distribution is running or stopped) and the version of WSL running the distribution (WSL 1 or WSL 2). Comparing WSL 1 and WSL 2. This command can also be entered as: wsl -l -v. Additional options that can be used with the list command include: --all to list all distributions, --running to list only distributions that are currently running, or --quiet to only show distribution names.

I’ve tried above stpes and working fine for me.

Happy learning !

Top comments (0)