1. What is WSL
Windows Subsystem for Linux (WSL for short) is a compatibility layer for running Linux binary executable files (ELF format) natively on Windows 10 and Windows Server 2019.
- Wikipedia
To use WSL, you need:
And enable "Windows Subsystem for Linux":
The following installation and other operation reference:
Installing Linux on Windows Using WSL
https://learn.microsoft.com/zh-CN/windows/wsl/install-manual
and
Windows Server Installation Guide
https://learn.microsoft.com/en-us/windows/wsl/install-on-server
2, WSL installation
2.1, Windows Server 2022, Windows 10 and above
On Windows 10 and above, you can search for the installation of Linux distributions in the Microsoft Store, such as Ubuntu:
Or you can use the command line:
1 | wsl --install |
Install the default subsystem (Ubuntu).
use
1 | wsl --list --online |
All supported systems can be listed:
abbreviation | system name |
---|---|
Ubuntu | Ubuntu |
Debian | Debian GNU/Linux |
kali-linux | Kali Linux Rolling |
openSUSE-42 | openSUSE Leap 42 |
SLES-12 | SUSE Linux Enterprise Server v12 |
Ubuntu-16.04 | Ubuntu 16.04 LTS |
Ubuntu-18.04 | Ubuntu 18.04 LTS |
Ubuntu-20.04 | Ubuntu 20.04 LTS |
The distribution can be specified with -d
. For example:
1 | wsl --install -d Ubuntu-20.04 |
2.2, Windows Server 2019
Before you can run a Linux distribution on Windows, you must enable the Windows Subsystem for Linux optional feature and reboot.
Execute in PowerShell:
1 | Enable-WindowsOptionalFeature-Online-FeatureNameMicrosoft-Windows-Subsystem-Linux |
Find the desired distribution on the Linux distribution download page, and download it to the folder (although it is Windows Server, it doesn’t even have a browser installed? IE is also available)
If there is no browser, execute:
1 | Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing |
Download Ubuntu 20.04 LTS.
Then execute:
1 | Add-AppxPackage .\Ubuntu.appx |
to install.
3, configure environment variables
implement
1 | $userenv = [System.Environment]::GetEnvironmentVariable("Path", "User") [System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User") |
Now, you can start your Ubuntu subsystem using Ubuntu.exe
or wsl
.
4, start and login
After the startup is complete, you will be asked to configure UNIX username
and password
, that is, the account password, which can be filled in casually, but the account cannot be root.
After that, WSL will log in with this account by default.
Therefore, you need to add sudo
prefix to enter commands in WSL, or use sudo -i
directly to switch to root.
5. Suggestions and Precautions
The default source is very, very slow, you can refer to:
Server Optimization (2) Replacing Software Sources
https://blog.tsinbei.com/archives/237/
The difference between WSL and virtual machines is that WSL core hosts share ports, so pay attention to possible port conflicts:
This issue will be addressed in the next article.
WSL Tutorial (1) Installation & Basic Config
Comments