> For the complete documentation index, see [llms.txt](https://docs.aic-eec.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aic-eec.com/computer-operation-systems/zero-to-linux-hero/anatomy-of-linux-kernel/setup-ubuntu-environment.md).

# Linux Environment for Developer

เตรียมสภาพแวดล้อมให้ Linux พร้อมทำงานในการคอมไพล์และสร้างเคอร์เนล

ติดตั้งเครื่องมือและไลบรารีที่เกี่ยวข้อง

```
sudo apt-get install git autoconf automake gdb fakeroot build-essential libtinfo6 libncurses6 libncursesw6 libncurses-dev xz-utils libssl-dev flex libffi-devel libelf-dev bisonsudo 
```

```bash
sudo su 
apt-get update -y
apt-get install -y yum
yum groupinstall "Development Tools"
```

หลังจากติดตั้งด้านบนสำเร็จให้รันคำสั่ง

> * autoconf
> * automake
> * gcc / g++
> * gdb
> * git
> * patch
> * flex

ตรวจสอบ kernel version ที่ใช้อยู่ เพื่อเลือก Linux Kernel Source ให้ใกล้เคียงที่สุด

```bash
uname -a                                                                                                      ─╯
Linux wiroon-ubuntu 5.19.0-46-generic #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 21 15:35:58 UTC 2 aarch64 aarch64 aarch64 GNU/Linux
```

ดาวโหลด Linux Kernel Source (ในที่นี้จะเลือกเวอร์ชัน `5.19.1`) เพื่อทำความเข้าใจโครงสร้างภายใน Linux OS

```sh
sudo wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.19.1.tar.gz
tar -xzvf linux-5.19.1.tar.gz
cd linux-5.19.1
```

```sh
cp /boot/config-$(uname -r) .config
make menuconfig
```

<figure><img src="https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MClo3nC-1US0rbK8Qau%2Fuploads%2FaZfzhfmU4ScG46V1rb6n%2Fmenuconfig.png?alt=media&amp;token=0e4dfcb6-a21a-42da-bde4-8d7eb411ebaf" alt=""><figcaption></figcaption></figure>

Output จาก `asciinema` จากการรันคำสั่ง `make menuconfig` --> [Link](https://github.com/Advance-Innovation-Centre-AIC/Linux_Operating_System_Class/blob/master/terminal_recorded/menuconfig.gif)
