# LinuxターミナルにLM Studio CLIをインストールする方法

1. LM Studio CLI を実行するために新しいターミナルを開くか、または次を使用します `tmux`
2. 入手 [LM Studio](https://lmstudio.ai/download) または以下を実行します（ダウンロードサイズは約1GB）

{% code overflow="wrap" %}

```bash
wget https://lmstudio.ai/download/latest/linux/x64?format=AppImage -O 'LM_Studio.AppImage'
chmod u+x ./LM_Studio.AppImage
```

{% endcode %}

<figure><img src="/files/12af0fcbffb183bf0e2d39c60c44cd06e7334bf6" alt=""><figcaption></figcaption></figure>

2. LM Studio を次で実行します

```bash
./LM_Studio.AppImage
```

次のような表示が出ることがあります:

<figure><img src="/files/99e961c8b8eb23e31280a88614e18abbea4f8138" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```
[802435:0215/073628.027773:FATAL:sandbox/linux/suid/client/setuid_sandbox_host.cc:166] SUID サンドボックス補助バイナリは見つかりましたが、正しく構成されていません。サンドボックスなしで実行するよりは中止します。
```

{% endcode %}

もしそうなら、代わりに以下を実行してください:

```bash
./LM_Studio.AppImage --no-sandbox
```

3. 特にデスクトップ環境のないクラウドインスタンスにいる場合、次のような表示が出ることがあります:

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

{% code overflow="wrap" %}

```
[807101:0215/073740.801969:ERROR:ui/ozone/platform/x11/ozone_platform_x11.cc:249] X サーバーまたは $DISPLAY がありません
[807101:0215/073740.802000:ERROR:ui/aura/env.cc:257] プラットフォームの初期化に失敗しました。終了します。
セグメンテーション違反 (コアダンプ)
```

{% endcode %}

その場合は、ターミナル内に「偽」のデスクトップシミュレータをインストールしてください:

```bash
sudo apt-get install xvfb
```

4. その後、次を使用します `xvfb` そして LM Studio を起動します:

```bash
xvfb-run --auto-servernum ./LM_Studio.AppImage --no-sandbox
```

<figure><img src="/files/94893a102b982e07c61aca7b7ee427decd9bc4cd" alt=""><figcaption></figcaption></figure>

5. 別のターミナルで、または CTRL+B+D の後に LM Studio の LMS / CLI を取得します `tmux`

```bash
~/.lmstudio/bin/lms bootstrap
```

<figure><img src="/files/569ab5184e2f28b4ce48eaf213a83b52dc9acdc6" alt=""><figcaption></figcaption></figure>

6. 新しいターミナルを開くか `tmux`  その後次を実行します:

```bash
lms
```

<figure><img src="/files/6c7ac345028315d751fdf1fb5f095cb1eb8f8d03" alt="" width="375"><figcaption></figcaption></figure>

もし次が表示されたら `-bash: lms: command not found` 次を実行してください `lms` 新しいターミナルウィンドウで！

7. 次のようなモデルをダウンロードします [Qwen3-Coder-Next](/docs/jp/moderu/qwen3-coder-next.md) 以下のように。ダウンロードが停止する場合は、次を参照してください [Hugging Face Hub、XETデバッグ](/docs/jp/ji-ben/troubleshooting-and-faqs/hugging-face-hub-xet-debugging.md)

{% code overflow="wrap" %}

```bash
pip install -U huggingface_hub
hf download unsloth/Qwen3-Coder-Next-GGUF \
    --local-dir unsloth/Qwen3-Coder-Next-GGUF \
    --include "*UD-Q4_K_XL*"
```

{% endcode %}

8. 次にモデルを以下でインポートします:

{% code overflow="wrap" %}

```bash
lms import \
    unsloth/Qwen3-Coder-Next-GGUF/Qwen3-Coder-Next-UD-Q4_K_XL.gguf \
    --symbolic-link --user-repo "unsloth/Qwen3-Coder-Next-GGUF" -y
```

{% endcode %}

次のような表示が出ることがあります `EEXIST: file already exists, symlink 'unsloth/Qwen3-Coder-Next-GGUF/UD-Q6_K_XL/Qwen3-Coder-Next-UD-Q6_K_XL-00001-of-00003.gguf' -> '~/.lmstudio/models/unsloth/Qwen3-Coder-Next-GGUF/Qwen3-Coder-Next-UD-Q6_K_XL-00001-of-00003.gguf'` これは単にそのモデルがすでに LM Studio にロードされていることを意味します。

すべての LM Studio モデルは次で確認できます:

```bash
ls ~/.lmstudio/models
```

8. モデルは次からも取得できます `lms get` 以下経由で:

```bash
lms get https://huggingface.co/unsloth/Qwen3-Coder-Next-GGUF@Q4_K_XL
```

<figure><img src="/files/050bef33085d2dd4e4edda7cdd07269f50aff17d" alt=""><figcaption></figcaption></figure>

次のように表示されます:

```
ダウンロードの最終処理中...
ダウンロードが完了しました。モデルは次でロードできます: 
lms load qwen3-coder-next
```

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

その後ロードします `lms load qwen3-coder-next`:

<figure><img src="/files/38511894ae9c88d98520e925d176ead322470eac" alt=""><figcaption></figcaption></figure>

9. そして LM Studio のサーバーを起動します:

```bash
lms server start --port 8001 --bind 127.0.0.1
```

次のように表示されます `成功！サーバーはポート 8001 で稼働中です`

9. 次に新しいターミナルで、OpenAI 互換のエンドポイントを通じてモデルを使用します:

```python
from openai import OpenAI
import json
openai_client = OpenAI(
    base_url = "http://127.0.0.1:8001/v1",
    api_key = "null",
)
model_name = next(iter(openai_client.models.list())).id
print(model_name)
completion = openai_client.chat.completions.create(
    model = model_name,
    messages = [{"role": "user", "content": "What is 2+2?"},],
)
print(completion.choices[0].message.content)
```

<figure><img src="/files/1d79c4a981e33cdf9bc0ed5d75d502bbd03edd51" 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://unsloth.ai/docs/jp/ji-ben/inference-and-deployment/lm-studio/how-to-install-lm-studio-cli-in-linux-terminal.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.
