How to Enable and Use Windows Subsystem for Linux (WSL) on Windows 10

Windows Subsystem for LinuxWSL setupDebian on Windows 10Ubuntu on WindowsWSL terminal
Published·Modified·

Windows Subsystem for Linux (WSL) is a compatibility layer that allows native execution of Linux binary executable files (ELF format) on Windows 10. Developed through a collaboration between Microsoft and Canonical, its goal is to enable users to download and decompress a pure Ubuntu 14.04 "Trusty Tahr" image to their local machine, allowing tools and utilities within the image to run natively on this subsystem.

Enabling the Linux Subsystem

Go to "Programs and Features" > "Turn Windows features on or off" > Check "Windows Subsystem for Linux" > Click OK and wait for Windows to install automatically.

After installation, a restart is required for the changes to take effect. Once restarted, open the Windows Store, search for "Debian" or "Ubuntu", and proceed with the installation.

Using the Linux Subsystem

In this guide, Debian is installed. Upon the first launch of WSL, you will be prompted to set up a username and password. Follow the on-screen instructions to complete the setup.

Note that the user set up above does not have root permissions. You can switch to the root user using sudo su -, or add the sudo command before running specific commands that require root privileges.

Updating Software Sources

Many commands are missing in the Linux subsystem and need to be installed manually via apt-get. First, run sudo apt-get update to update the system software, then use sudo apt-get install xxx to install the desired software.

However, connecting to the official Debian source from within China can be very slow. You can switch to the NetEase mirror by following these steps:

# 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 prefer to switch to the Aliyun 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

The Windows 10 Subsystem (WSL) allows for native execution of Linux commands. Unfortunately, the native window does not support multiple tabs. However, many third-party applications now support setting WSL as the terminal. For example, MobaXterm allows you to configure the terminal as WSL, enabling multi-tab usage within the MobaXterm environment.

This article references content from: Debian Mirror Usage Help