# ติดตั้ง WSL 2

1. ตรวจสอบเวอร์ชั่น windows ที่รองรับ WSL2

   1.1 กดปุ่ม `windows logo key + R` แล้วพิมพ์ว่า winver  วิธีการเช็คเวอร์ชั่นของ Windows ที่ติดตั้ง

   System requirement

   * * For x64 systems: **Version 1903** or higher, with **Build 18362** or higher.
     * For ARM64 systems: **Version 2004** or higher, with **Build 19041** or higher.

![](/files/-MNYZ9iVkzVeMA8AOkWy)

&#x20;       1.3 ไปที่ Search พิมพ์ค้นหา windows powershell คลิ๊กขวาเลือก Run as administrator

![](/files/-MNY_Q84Ep9qTBPOq23K)

&#x20;       1.4. พิมพ์คำสั่งดังนี้

```
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```

&#x20;      1.5. พิมพ์คำสั่งดังนี้

```
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
```

&#x20;     1.6. Restart เครื่อง

2\. ดาวน์โหลด [Linux kernel update](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi) แล้วทำการติดตั้ง

![](https://paper-attachments.dropbox.com/s_9749D5A73F48B7159351521E9F40D4E63444EDB865F015B313407708D5057BD0_1606912048020_image.png)

3\. ติดตั้ง Ubuntu 18.04 &#x20;

&#x20;    3.1 ไปที่เมนู Search ของ windows ค้นหา Microsoft store

&#x20;    3.2 พิมพ์  Ubuntu 18.04 LTS ที่ช่องค้นหา

&#x20;    3.3 คลิ๊ก get เพื่อ ติดตั้ง

&#x20;    3.4 หลังติดตั้งเสร็จ คลิ๊ก Launch เพื่อเปิดโปรแกรม&#x20;

![](/files/-MNYcbIr6JgYbeMcOs4_)

&#x20;    3.5 ตั้งชื่อ Username กับ Password

{% hint style="info" %}
ตรงนี้สำคัญมากถ้าเราตั้งชื่อผิดหรือตั้ง password แล้ว แต่ลืม password วิธีแก้มีแค่วิธีเดียวคือลบ Ubuntu ทิ้ง แล้วก็ติดตั้งใหม่เท่านั้น
{% endhint %}

<figure><img src="/files/98fzH2dwaUlqWRJAxNgL" alt=""><figcaption><p>ตัวอย่างนี้คือการตั้งชื่อ Username ว่า Chhun แล้วก็ใส่ Password 1234 เข้าไป. Password จะเป็นการปิดการมองเห็น ฉะนั้นควรระวังเวลาใส่ password เข้าไป</p></figcaption></figure>

4\. เปิด Windows Powershell อีกครั้ง

&#x20;   4.1 ตรวจสอบ version ของ WSL พิมพ์คำสั่งดังนี้

```
wsl --list --verbose
```

![](/files/-MNYee_a1Uv-dT5yrs-1)

&#x20;  4.2 ตั้งค่า wsl2 ให้เป็น default version ด้วยคำสั่ง

```
wsl --set-default-version 2
```

![ตัวอย่าง](/files/-MNYf2xBFniSKC9WU1Jn)

หลังจากเช็คเวอร์ชั่นว่าพร้อมใช้งานแล้วเราสามารถเปลี่ยนเวอร์ชั่น WSL เป็น 1 และ 2 ได้โดยใช้คำสั่งด้านล่าง

```
wsl --set-version Ubuntu-18.04 2
```

หรือ

```
wsl --set-version Ubuntu-18.04 1
```

ตามเวอร์ชั่น WSL ที่เราต้องการ (ในคลาสเรียนนี้ใช้เวอร์ชั่น2)

จากนั้นเปิด Ubuntu ที่ติดตั้งแล้วทำตาม ขั้นตอนนี้ (Debian) ได้เลย

&#x20;   &#x20;

แหล่งอ้างอิง

{% embed url="<https://docs.microsoft.com/en-us/windows/wsl/install>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/c-c++-for-embedded-programming/development-environment-preparation/wsl-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
