# Advance Process Mgmt. Commands

### แสดงความสัมพันธ์ของโปรเซสทั้งหมดในระบบด้วยคำสั่ง pstree

```shell-session
$ pstree -n -p -c
```

<figure><img src="/files/xJxTSGx4tRBKwAjlErFR" alt=""><figcaption></figcaption></figure>

### แสดงความสัมพันธ์และหมายเลขของแต่ละโปรเซสด้วยคำสั่ง pstree

โดยการใช้ `pstree` ตามด้วย option `-p`  และ `-u <ชื่อ user>` ดังตัวอย่าง

```shell-session
$ pstree -p -u <ชื่อ user>
```

<figure><img src="/files/jXfmgUiF56nd1RvGtdf9" alt=""><figcaption></figcaption></figure>

```shell-session
$ pstree -p -u <ชื่อ user> | grep terminal
```

<figure><img src="/files/jp1a67CwdbRcgFD1GpDY" alt=""><figcaption></figcaption></figure>

### ค้นหาหมายเลขโปรเซสด้วยคำสั่ง pgrep

```shell-session
$ pgrep emacs-gtk 
หรือ
$ pgrep emacs 
```

<figure><img src="/files/4CuzdbRbiGpKDMLxs5Au" alt=""><figcaption></figcaption></figure>

ในกรณีใช้คำสั่ง ps ก็สามารถแสดงหมายเลขโปรเซสได้เช่นเดียวกัน ดังตัวอย่าง

```shell-session
$ ps -e | grep emacs-gtk
หรือ 
$ ps -e | grep emacs
```

<figure><img src="/files/0sNav8ybMwWF1qBhBieN" alt=""><figcaption></figcaption></figure>


---

# 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/computer-operation-systems/linux-os-dev.-engineer/process-management/advance-process-mgmt.-commands.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.
