Quick Reference

Cheatsheets

Practical command references for Linux, networking, servers, containers, databases, and more.

Cheatsheet#ollama-llm-cheatsheet

Ollama (Local LLM) Cheatsheet

Ollama allows you to get up and running with large language models locally.

Installation

# macOS / Linux
curl -fsSL https://ollama.com/install.sh | sh

Basic Commands

ollama serve                   # Start the Ollama server (usually runs as a service in the background)
ollama run llama3              # Download (if needed) and run the LLaMA 3 model
ollama run mistral             # Run the Mistral model

Model Management

ollama list                    # List all locally downloaded models
ollama pull codellama          # Download a model without running it
ollama rm llama2               # Delete a local model to free up space
ollama show llama3             # Show metadata and system prompt for a model

Creating Custom Models (Modelfile)

You can create a custom model by writing a Modelfile.

  1. Create a file named Modelfile:
FROM llama3
 
# Set the temperature (higher = more creative, lower = more coherent)
PARAMETER temperature 0.7
 
# Set the system message
SYSTEM """
You are Mario from Super Mario Bros. Answer as Mario, only using his catchphrases.
"""
  1. Build and run the model:
ollama create mario -f ./Modelfile
ollama run mario

API Usage

Ollama provides a local REST API (default port 11434).

curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "Why is the sky blue?",
  "stream": false
}'