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
    
  2. เรียกใช้โดยเปิด PowerShell โดยสิทธิ์ administrator
  3. cd ไป folder ที่ save ไฟล์ WSL2_install_Ubuntu.ps1 เช่น
    cd C:\Users\Public\Gits\phunsanit\snippets\WSL
  4. run โดยใช้
    ./WSL2_install_Ubuntu.ps1
    แล้ว enter แค่นี้ก็ติดตั้ง Ubuntu ใน windows ได้แล้ว
  5. เปิด terminal ใหม่ จะเห็นว่ามี Ubuntu เพิ่มขึ้นมา

ดูเพิ่มเติม

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

Plus emotional magic to the knowledge of logic.

Exit mobile version