Photo by Gabriel Heinzer on Unsplash
You can use WSL
to run the Linux-based
program on the Windows
WSL2 Version
If your Windows 10 has been upgraded to the 20H1/20H2
or higher version
, then the default version of the WSL will be WSL2
Enable Hyper-V
You can go to the Control Pannel
or search the programs
keyword, then click Add or remove programs
Click the Programs and Features
on the right side.
Click Turn Windows features on or of
to open the Windows Features
window
And enable all the Hyper-V
options.
Active WSL
Run the PowerShell
as an administrator
, then run the following 2 commands
to activate wsl
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart windows
after run the active wsl commands to active WSL
Confirm WSL Active Status
Go back to the original Windows Features
window to confirm if the following 2 options are all enabled
- Virtual Machine Platform
- Windows Subsystem for Linux
Change WSL Version
Make sure your WSL version is set to 2
wsl --set-default-version 2
Download the Ubuntu from the Microsoft Store
Hint: You can download any version of the Linux that you want, but here is using
Ubuntu 20.04 LTS
Open Microsoft Store the search Ubuntu
to download the Ubuntu system
After install fininsh, then open the Ubuntu
, and try to setup you account & password
on the Ubuntu
. Then you can close this window.
Show available Linux version from the WSL
Run the wsl -l
can show all of the available Linux version
wsl -l
But I only install 1 version of Linux, so here is only 1 version that shows on the screen.
If you install multi-version of Linux, it will show all of the Linux versions right here.
Use WSL to connect specific Linux version
wsl -d
Linux System Version Name
wsl -d Ubuntu-20.04
Run the wsl -d
to access the specific Linux version.
Then you will see all of the Linux files
are all synchronized
with the Windows
on the /mnt
path
So you can edit or change anything
you want on the Windows environment
, then execute it on the Linux environment
WSL Commands
Commands | Description |
---|---|
wsl -h |
Show all of the wsl commands |
wsl -l |
Show all of the available Linux version |
wsl -d |
Connect specific Linux version |
Reference
- 什麼是Windows 子系統 Linux 版 | Microsoft Learn
- 使用WSL2在Windows下快速打造Linux開發環境(含Docker) - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天
Donate KJ 贊助作者喝咖啡
如果這篇文章對你有幫助的話,可以透過下面支付方式贊助作者喝咖啡,如果有什麼建議或想說的話可以贊助並留言給我
If this article has been helpful to you, you can support the author by treating them to a coffee through the payment options below. If you have any suggestions or comments, feel free to sponsor and leave a message for me!
方式 Method | 贊助 Donate |
PayPal | https://paypal.me/kejyun |
綠界 ECPay | https://p.ecpay.com.tw/AC218F1 |
歐付寶 OPay | https://payment.opay.tw/Broadcaster/Donate/BD2BD896029F2155041C8C8FAED3A6F8 |