Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Installing Linux with Windows WSL

Installing Linux with Windows WSL

WSL (Windows Subsystem for Linux) It is a subsystem provided by Microsoft for Windows users. It allows you to run Linux natively on Windows (not a virtual machine, not a dual-boot system), using Linux tools such as Bash, apt, gcc, Python, and Node.js directly.

Differences Between WSL Versions

Feature WSL1 WSL2
Kernel Architecture Translate system calls (compatibility layer) A real Linux kernel (lightweight virtual machine)
Performance (file access) Faster Windows <-> Linux access Faster internal Linux <-> Linux access
Startup speed is usually faster than Slightly slower
Docker Support Not supported Fully supported
System Resource Usage less Slightly higher

it is recommended to use WSL2, with stronger compatibility and more complete features.


Installation Steps (Using WSL2 as an Example)

Precondition

Method 1: One-Click Installation (Recommended)

wsl --install

This command automatically:

After installation, simply restart the system once.

Method 2: Manual Installation (for Custom Needs)

1. Enable the WSL feature and Virtual Machine Platform

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

2. Download and install the Linux kernel update package

Download address:https://aka.ms/wsl2kernel

3. Set the default WSL version to WSL2

wsl --set-default-version 2

4. Install a Linux distribution from the Microsoft Store (such as Ubuntu)

It can also be installed via the command line:



wsl --install -d Ubuntu


Common Command Quick Reference

Command Description
wsl Launch the default Linux
wsl --list --verbose View installed distributions and versions
wsl --set-version Ubuntu 2 Set Ubuntu to use WSL2
wsl --install -d Debian Install a specified distribution
wsl --shutdown Shut down all WSL instances
wsl -e bash Launch the Linux Shell with Bash

Daily Usage Guide

How to Access Windows Files?

In WSL, Windows files are mounted under directories such as /mnt/c and /mnt/d:



cd /mnt/c/Users/你的用户名/Desktop

How to Access WSL Files?

Access from Windows:



\\wsl$\Ubuntu\home\your_username

Or enter in the File Explorer address bar: \wsl$


Recommended Companion Tools

Tool Description
Windows Terminal A multi-tab terminal with color support and custom configuration
VS Code + Remote WSL Edit Linux files directly in VS Code
oh-my-zsh / fish Beautify the terminal and improve the operating experience
tmux / screen A multi-terminal management tool

How to Uninstall or Reset?

# 卸载某个 Linux 发行版

wsl --unregister Ubuntu



# Reset all WSL data (dangerous operation)

wsl --unregister <发行版名>