การติดตั้ง Windows Subsystem for Linux 2 สำหรับลง linux ใน windows สามารถติดตั้งง่าย ๆ โดยใช้ PowerShell ( download )
- สร้างไฟล์ WSL2_install_Ubuntu.ps1 โดยมีเนื้อหา
123456789101112131415
<#
PowerShell install Windows Subsystem for Linux 2 (WSL2)
#by pitt phunsanit
#>
#Enabling Windows Services for the WSL.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
#Windows' Virtual Machine Platform.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
#set the default version of the WSL to version 2.
wsl --set-default-version 2
#install WSL
wsl --install -d Ubuntu
#list installed distributions
wsl -l -v
- เรียกใช้โดยเปิด PowerShell โดยสิทธิ์ administrator
- cd ไป folder ที่ save ไฟล์ WSL2_install_Ubuntu.ps1 เช่น
cd C:\Users\Public\Gits\phunsanit\snippets\WSL
- run โดยใช้
./WSL2_install_Ubuntu.ps1
แล้ว enter แค่นี้ก็ติดตั้ง Ubuntu ใน windows ได้แล้ว - เปิด terminal ใหม่ จะเห็นว่ามี Ubuntu เพิ่มขึ้นมา
ดูเพิ่มเติม
About the author