Run Ollama Locally in 2026: Every Command You Need
Complete Ollama command reference: install, pull models, chat, OpenAI-compatible API server, Modelfile and environment variables.
💡 What You Will Learn
Complete Ollama command reference: install, pull models, chat, OpenAI-compatible API server, Modelfile and environment variables.
📜 Table of Contents
Run Ollama Locally: Every Command You Need
Ollama (177k+ stars on GitHub) is the easiest way to run local LLMs in 2026. This is a copy-paste command reference.
Install
- macOS/Linux:
curl -fsSL https://ollama.com/install.sh | sh - Windows: download the installer from ollama.com
- Docker:
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
Verify with ollama --version.
Model Management
| Command | Purpose | Example |
|---|---|---|
| ollama pull | download a model | ollama pull qwen2.5:7b |
| ollama list | list downloaded models | ollama list |
| ollama rm | delete a model | ollama rm qwen2.5:7b |
| ollama cp | clone / rename | ollama cp qwen2.5:7b my-qwen |
Models are named name:tag (e.g. llama3.2:3b, qwen2.5:7b).
Chat
ollama run qwen2.5:7b
In-chat shortcuts: /bye to exit, /help for all shortcuts, /set parameter num_ctx 8192 to raise context. One-shot: ollama run qwen2.5:7b "explain RAG in one sentence".
API Server
ollama serve listens on port 11434 and exposes an OpenAI-compatible /v1/chat/completions endpoint, so any OpenAI SDK can point at http://localhost:11434/v1. Native endpoints: /api/generate (single completion) and /api/chat (multi-turn). ollama ps shows models loaded in memory.
Modelfile (custom models)
FROM qwen2.5:7b
SYSTEM "You are a careful technical editor."
Save as Modelfile, run ollama create my-editor -f Modelfile, then ollama run my-editor. Useful directives: PARAMETER temperature 0.3, PARAMETER num_ctx 8192.
Environment Variables
OLLAMA_KEEP_ALIVE: how long a model stays in memory (e.g. 30m, -1 = always)OLLAMA_MODELS: model storage directoryOLLAMA_HOST: bind address (0.0.0.0:11434 for LAN access)
Key Parameters
num_ctx (context window, raise for long documents), temperature (0.8 default), top_p (0.9), num_predict (max output tokens, -1 unlimited).
FAQ
Q: Can I run without a GPU? A: Yes, CPU runs 7B at about 2-5 token/s; GPU is typically 5-20x faster.
Q: Long documents get truncated? A: Raise num_ctx (--num-ctx 8192 or in Modelfile); larger context uses more memory.
Q: LAN access fails? A: Set OLLAMA_HOST=0.0.0.0:11434 and open the firewall port.
Note: model tags and versions change over time; check the official docs.
❓ FAQ
Does Ollama need a GPU?
No - it runs on CPU, but GPU (CUDA/Metal) gives 5-20x speedup.
Is the API OpenAI-compatible?
Yes, the /v1/chat/completions endpoint works with most tools that expect OpenAI.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only โ no paid placements.
