Tag Archive WSL

Byphunsanit

WSL: PowerShell Installing

การติดตั้ง Windows Subsystem for Linux 2 สำหรับลง linux ใน windows สามารถติดตั้งง่าย ๆ โดยใช้ PowerShell ( download )

  1. สร้างไฟล์ WSL2_install_Ubuntu.ps1 โดยมีเนื้อหา
<#
PowerShell install Windows Subsystem for Linux 2 (WSL2)
#by pitt phunsanit
https://pitt.plusmagi.com
#>
#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:\UsersGit\phunsanit\snippets\WSL
  • run โดยใช้ .WSL2_install_Ubuntu.ps1แล้ว enter แค่นี้ก็ติดตั้ง Ubuntu ใน windows ได้แล้ว
  • เปิด terminal ใหม่ จะเห็นว่ามี Ubuntu เพิ่มขึ้นมา

ดูเพิ่มเติม

  1. Windows Subsystem for Linux Documentation
  2. Basic commands for WSL