Enabling Linux Subsystem (WSL) on Windows 10

Publish: 2019-04-15 | Modify: 2019-12-18

Windows Subsystem for Linux (WSL)

WSL, short for Windows Subsystem for Linux, is a compatibility layer that allows Linux binary executables (in ELF format) to run natively on Windows 10. It is developed by Microsoft in collaboration with Canonical, with the goal of enabling the download and extraction of a pure Ubuntu 14.04 "Trusty Tahr" image on users' local computers, and allowing the tools and utilities within the image to run natively on this subsystem.

WSL

Enabling the Linux Subsystem

To enable the Windows Subsystem for Linux, go to "Programs and Features" - "Turn Windows features on or off" - check the box for "Windows Subsystem for Linux", and then click OK to wait for Windows to install it automatically.

Enable WSL

Enable WSL

After the installation is complete, you need to restart your computer for the changes to take effect. Once restarted, open the Windows Store, search for "Debian" or "Ubuntu", and then install it.

Install Linux

Using the Linux Subsystem

In this example, xiaoz installed Debian. When you first start WSL, it will prompt you to set up an account and password. Follow the prompts to complete the setup.

Set up WSL

Note that the user you set up above does not have root privileges. You can switch to the root user by executing sudo su -, or use the sudo command when necessary to run commands that require root privileges.

Updating the Software Sources

Many commands are not available in the Linux subsystem and need to be installed using apt-get. First, execute the command sudo apt-get update to update the system software, and then execute sudo apt-get install xxx to install the software.

However, the connection to the Debian official source is very slow in China. Here, you can modify the source to use Netease's source. The operation method is as follows:

# Backup
mv /etc/apt/sources.list /etc/apt/sources.list.bak
vi /etc/apt/sources.list
# Add the following content (163 source)
deb http://mirrors.163.com/debian/ jessie main non-free contrib
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib

# Update again
sudo apt-get update

If you need to change to Aliyun's source, use the following content:

vi /etc/apt/sources.list
# Add the following content
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
# Update
sudo apt update
sudo apt upgrade

Summary

Windows 10 Subsystem (WSL) can run Linux commands natively, but unfortunately, the window does not support running multiple tabs. However, many third-party software already support setting WSL as the terminal, such as MobaXterm, which allows you to use WSL in a multi-tab environment.

WSL with MobaXterm

This article refers to Debian Mirror Usage Help for some of its content.


Comments