Windows CLI - Installing WSL
Windows CLI - Installing WSL

Windows CLI - Installing WSL

Become a cyber pro by building your skills in the National Cyber League!

What is WSL?

Windows Subsystem for Linux (WSL) is a system to run Linux executables on a Windows system. WSL is installed and enabled for Windows 11, Windows 10, and Windows Server 2019. Most modern computers running the Windows operating system can run WSL.

WSL 1 was released in 2016 and WSL 2 was released in 2019. WSL2 runs a Linux kernel inside of a lightweight virtual machine using Hyper-V features.

Running WSL starts up a bash process (command line interface). Most Linux executables can run within WSL, including networking applications, graphical applications, and using the GPU. WSL also has access to the Windows filesystem, thus a user can access their files in their C drive.

Why use WSL?

If you want to run a Linux-like system, WSL is one of many choices. Other choices are running a Docker container or running another Virtual Machine (VM) within Windows. The advantages and disadvantages of each method is shown in the table below.

WSL vs Container vs VM

_WSLContainerVM

Resources

Light-weight, built-in

Light-weight

Heavy-weight with whole VM installation

Distributions

Ubuntu, Kali, etc.

Applications only

Ubuntu, Kali, etc.

Process

Bash and other applications

Bash and other applications

Full operating system capabilities

Interoperability

Can easily access Windows filesystem but not other way around

Can access certain mount points but not whole filesystem

Can access Windows filesystem or specific directories via Shared Folders

Examples

WSL

Docker

VMWare, VirtualBox

Installing WSL

To install WSL, open up Windows Powershell as shown in the screenshot below.

image

Then type the following commands to install. You might then have to restart your computer.

wsl --install

To list all available Linux distributions

wsl --list --online
wsl --install -d <distribution>

For example, to install Ubuntu

wsl --install -d Ubuntu

Linux distributions can also be installed using the Microsoft Store.

Uninstalling WSL

To uninstall WSL, first you have to "unregister" existing Linux distributions by running the following commands and as shown in the screenshots below.

wsl -l
wsl --unregister <distribution>
image
image
💡
You can check out the official Microsoft documentation on installing WSL at https://docs.microsoft.com/en-us/windows/wsl/install and https://docs.microsoft.com/en-us/windows/wsl/install-manual for older versions of Windows 10.

Using WSL

To run WSL, search for "WSL" or click on the Start Menu → <distribution> (for example, Start Menu → Ubuntu)

By default, WSL will open up a bash terminal. Note that most Linux applications can be compiled and run but not everything is implemented.

The Windows C drive is accessible by the folder /mnt/c

You can now use Linux inside Windows!

This post was not affiliated, associated, authorized, endorsed by, or in any way officially connected with Microsoft. The Windows name and marks are registered trademarks of Microsoft and are only used for informational purposes.

Published by DECT