WSL puts Linux on Windows desktops



To begin, open PowerShell with administrative privileges and install WSL with:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

After successfully completing the install, the system has to reboot. Next, open Microsoft Store. A search for Linux reveals numerous results, including several well-known distributions, such as openSUSE, various versions of SUSE Enterprise, Debian, Ubuntu, and Kali Linux, which is popular among pentesters and forensics experts. For this example, install Kali Linux and Ubuntu. As soon as the store has finished downloading the distributions, you will find both as icons in the start menu. Clicking on them opens a console window with a Linux shell. Alternatively, you can start Linux instances at the Windows command prompt by typing kali or ubuntu. The generic wsl command starts the configured default Linux distribution. You can find out which this is with the Windows command wslconfig /list, which lists all Linux distributions installed in WSL. If you installed Kali Linux first, it is automatically the default. Typing

wslconfig /setdefault Ubuntu

changes the default to Ubuntu. If a Linux instance without an interactive shell is still active with background processes, you can terminate it with:

wslconfig /terminate <Name-of-Distro>

The first start is followed by a basic configuration of the distribution. You are prompted to create a user with a password that does not have to be the same as your Windows user account password. At this point, you can update both Linux instances with the familiar commands

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get clean

because of the similar substructure used by Kali Linux and Ubuntu.

Working with the Filesystem

By default, the Linux shell sets the working directory to /home/username; in the Windows NTFS filesystem, this is equivalent to the path:


Alternatively, WSL also adds an entry to the Windows Explorer context menu. If you hold down the Shift key in any folder and right-click the context menu, you will find an Open Linux Shell here entry that starts the distribution configured as the default in the desired directory.

However, this initially only works for the system's connected drives. WSL automatically mounts all known Windows drives with their respective drive letters under paths such as /mnt/c and /mnt/d. If you also plug in a USB stick that Windows connects as drive E:, you first have to mount it with DrvFs under Linux:

sudo mkdir /mnt/e
sudo mount -t drvfs E: /mnt/e

This works just as well with network shares that are connected by drive letters under Windows, or alternatively, you can mount a drive directly with

sudo mkdir /mnt/share
sudo mount -t drvfs '\\server\share' /mnt/share

by specifying the Universal Naming Convention (UNC) path.

Linux and Windows Commands

In the shell, all commands and applications available under Linux are available for working with Windows folders and files. However, even without having a Linux shell open permanently, interoperability between the two worlds is ensured [6]. Thanks to wsl.exe, you can launch individual Linux commands (path specifications must, of course, follow the conventions for Linux) directly from a Windows command prompt: Open the cmd.exe command prompt and type:

wsl ls -la "/mnt/c/Program Files"

You will then see the output of the ls command in Windows; WSL executes this on the default Linux instance. Conversely, you can run Windows executable files in an open Linux shell just as easily. Typing notepad.exe opens the Windows editor in the shell. Passing in parameters to the respective application when calling it is also possible. Path specifications, in turn, need to comply with Windows conventions.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our ADMIN Newsletters
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs

Support Our Work

ADMIN content is made possible with support from readers like you. Please consider contributing when you've found an article to be beneficial.

Learn More”>


		<div class=