WSL

What is WSL?

Windows Subsystem for Linux (WSL) is an environment in Windows 10 for running unmodified Linux binaries in a way similar to LinuxContainers.

What is WSL 2?

WSL(1) runs Linux binaries by implementing a Linux API compatibility layer partly in the Windows kernel while WSL 2 uses the Linux kernel itself in a lightweight VM to provide better compatibility with native Linux installations.

Enabling WSL in Windows 10

Before installing the Ubuntu apps WSL has to be enabled in one of the following ways.

Using PowerShell

  1. Open PowerShell as Administrator and run:

       1  Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    
  2. Restart your computer when prompted.

Using the GUI for enabling Windows features

  1. Open the Control Panel

  2. Visit Programs and Features ' submenu Turn Windows features on or off

  3. Select Windows Subsystem for Linux

  4. Click OK

  5. Reboot

Ubuntu on WSL

Installing Ubuntu

Ubuntu apps can be installed on WSL from the Microsoft Store or using the offline installers. Supported Ubuntu releases are available as separate apps:

  • Ubuntu 16.04 LTS (Xenial) is the first release available for WSL. It supports the x64 architecture only. (offline installer: x64)

  • Ubuntu 18.04 LTS (Bionic) is the current LTS release and the first one supporting ARM64 systems, too. (offline installers: x64, ARM64)

  • Ubuntu (without the release version) always follows the recommended release, switching over to the next one when it gets the first point release. Right now it installs Ubuntu 18.04.

The apps are like installation kits. Each app creates a separate root file system in which Ubuntu shells are opened but app updates don’t change the root file system afterwards. Installing a different app in parallel creates a different root file system allowing you to have both Ubuntu LTS releases installed and running in case you need it for keeping compatibility with other external systems. You can also upgrade your Ubuntu 16.04 to 18.04 by running ‘do-release-upgrade’ and have three different systems running in parallel, separating production and sandboxes for experiments.

Ubuntu WSL distribution tarball daily builds are also available for download:

They can be installed using the wsl command or Third Party Tools:

  •    1  wsl --import <DistributionName> <InstallLocation> <FileName>
    

Running Ubuntu

The Ubuntu Terminal can be started via the app tiles in the Start menu, from the Windows command line using the wsl command, or by simply running ubuntu, ubuntu1804, etc. from the command line.

Keeping Ubuntu up-to-date in WSL

WSL runs its specialized init system instead of SystemD and does not run standard Ubuntu services. Due to the services not running software updates are not applied automatically. Please keep your WSL installation using APT maintenance commands regularly.

Performance

Ubuntu's performance in WSL(1) can be close to bare metal Ubuntu installations in mostly CPU-intensive tasks but file operations are much slower in WSL (see tests).

In WSL 2, CPU intensive tasks are measured to be slightly slower and file operations are generally faster than on WSL(1). (see early tests)

To improve performance of the file operations some sites suggest disabling anti-virus software. This puts your system at risk and we highly recommend against doing so.

Running Graphical Applications

The X Window System Architecture allows running the X server and the X clients on separate systems and in WSL's case the X server can be a native Windows server providing even OpenGL acceleration and the clients can be the graphical Linux applications running in the WSL environment.

Install one from several X servers available for Windows and start it before entering the WSL environment:

If graphical applications can't connect to the running X server automatically paste the following commands to the terminal before starting the applications or set them on every login by adding them to ~/.bashrc:

  •    1  export DISPLAY=:0
       2  export LIBGL_ALWAYS_INDIRECT=1
    

Enabling Sound

Sound does not work yet in WSL by default, but it can be enabled by installing the PulseAudio server on Windows following this guide https://token2shell.com/howto/x410/enabling-sound-in-wsl-ubuntu-let-it-sing/ and installing the libpulse0 package on Ubuntu:

   1 sudo apt install libpulse0

Reporting Issues

Reporting WSL-specific Issues

Due to the differences in running Ubuntu on real hardware and on WSL instead of using standard Ubuntu channels please report issues at https://github.com/Microsoft/WSL/issues/ where the issues can't be reproduced outside of WSL environments.

Reporting Issues in Ubuntu

Please use the standard Ubuntu channels described in ReportingBugs.

Reporting Issues in the Ubuntu Apps

Please report issues of the Ubuntu apps at https://bugs.launchpad.net/ubuntuwsl.

Third-party tools

Enthusiasm among the power-user community has led to the development of many useful enhancements to the base WSL feature set. Listed below are links to some of them.

WSL Manager GUIs

  • WSL Hub Offers a graphical interface for installing and managing Linux distributions on Windows 10 & Server 2016, from release 19H1 onwards. Allows users to install Linux distros with or without using the Microsoft Store, or even their own custom tarballs and view the status of them at a glance. Other features include: creating backups and snapshots of installed WSL distros, monitor disk space used, retrieve registry keys associated with them, create custom shortcuts that launch a desired distro with extra invocation flags, and mounting of their Linux filesystems without running them.

Command line tools

  • WSLInstall Install any GNU/Linux distribution userspace in Windows Subsystem for Linux (WSL) with compressed RootFS tarballs, Docker containers or ISO files.

WSL (last edited 2019-08-05 15:09:26 by rbalint)