Skip to main content

Introduction

Ollama provides a powerful command-line interface for running and managing large language models locally. The CLI allows you to pull models from registries, run them interactively or in scripts, and manage your model library.

Basic Usage

ollama [command] [options]

Available Commands

serve

Start the Ollama server

run

Run a model interactively

pull

Pull a model from a registry

push

Push a model to a registry

create

Create a custom model

show

Show model information

list

List available models

ps

List running models

stop

Stop a running model

rm

Remove a model

launch

Launch the Ollama menu or integrations

Common Patterns

Quick Start

Pull and run a model in one command:
ollama run llama3.2
If the model isn’t present locally, it will be pulled automatically.

Piping Input

Use Ollama in Unix pipelines:
cat document.txt | ollama run llama3.2 "Summarize this:"

Non-Interactive Mode

Run a one-off prompt without entering interactive mode:
ollama run llama3.2 "What is the capital of France?"

JSON Output

Request structured JSON responses:
ollama run llama3.2 --format json "List 3 colors as a JSON array"

Keep Models Loaded

Control how long models stay in memory:
# Keep loaded for 10 minutes
ollama run llama3.2 --keepalive 10m

# Unload immediately after response
ollama run llama3.2 --keepalive 0

# Keep loaded indefinitely
ollama run llama3.2 --keepalive -1

Environment Variables

OLLAMA_HOST
string
default:"http://127.0.0.1:11434"
The host address for the Ollama server
OLLAMA_MODELS
string
default:"~/.ollama/models"
Directory where models are stored
OLLAMA_NOHISTORY
boolean
default:"false"
Disable saving command history in interactive mode
OLLAMA_EDITOR
string
Editor to use for multi-line input in interactive mode

Global Flags

--version
boolean
default:"false"
Show version information
--verbose
boolean
default:"false"
Show detailed output including timing information
--nowordwrap
boolean
default:"false"
Disable automatic word wrapping in output

Exit Codes

  • 0 - Success
  • 1 - General error
  • Non-zero - Specific error occurred (check error message)

Getting Help

Get help for any command:
ollama [command] --help

Next Steps

Running Models

Learn how to run and interact with models

Creating Models

Create custom models with Modelfiles