Running LLMs locally

Sefism.

Chapter 01

Getting started with Ollama

What Ollama is, how to install it, and the handful of commands that cover everyday use.

What Ollama is

What
An open-source tool that downloads open-weight models, runs them on your CPU or GPU, and serves them through a CLI and a local HTTP API on port 11434.
Why
Private, offline and free per token: prompts never leave the machine, which suits sensitive data, prototyping and learning.

Watch out

Expecting a laptop model to match the largest hosted models on hard reasoning; pick tasks that suit small models.

Installing

What
Desktop apps for macOS and Windows, a one-line install script for Linux that sets up a systemd service, and an official Docker image.
Why
After install a background server is running, so the CLI and any app can use models straight away.
Shell
curl -fsSL https://ollama.com/install.sh | sh
ollama --version
systemctl status ollama
curl http://localhost:11434/api/version

ollama run

What
Downloads the model if needed, loads it and opens an interactive chat, or answers a single prompt passed as an argument.
Why
The fastest way to try a model and judge whether it suits your task.
Shell
ollama run llama3.2
ollama run qwen3:8b "Explain a mutex in two sentences."
cat notes.md | ollama run llama3.2 "Summarise this:"
ollama run llama3.2 --verbose

Chat session commands

Also called /set, /show, /bye

What
Inside ollama run, slash commands change settings for the session: /set parameter num_ctx 8192, /set system "...", /show info, /save name, /clear and /bye. Triple quotes start multi-line input.
Why
You can experiment with parameters and a system prompt interactively, then save the result as a new model.

pull, list, rm and show

What
pull downloads or updates a model, list shows downloaded models and their sizes, rm deletes one, and show prints its architecture, parameters, context length, template and licence.
Why
Models are gigabytes each; managing them keeps disks from filling up.
Shell
ollama pull gemma3:4b
ollama list
ollama show gemma3:4b
ollama show gemma3:4b --modelfile
ollama rm gemma3:4b

ps, stop and keep-alive

Also called keep_alive, OLLAMA_KEEP_ALIVE

What
ollama ps lists loaded models, their memory use and whether they run on GPU, CPU or both. Models unload after an idle period (five minutes by default); ollama stop unloads one now.
Why
Loading a large model takes seconds, so keep it loaded while working and free memory when done.
Shell
ollama ps
ollama stop llama3.2
OLLAMA_KEEP_ALIVE=1h ollama serve

The server and OLLAMA_HOST

What
ollama serve runs the server, normally started for you by the app or service. OLLAMA_HOST sets its address, 127.0.0.1:11434 by default, and also tells the CLI which server to talk to.
Why
Pointing the CLI at another machine lets a laptop use a GPU box on the network.
Shell
OLLAMA_HOST=gpu-box.lan:11434 ollama list
OLLAMA_HOST=gpu-box.lan:11434 ollama run llama3.2

Where models are stored

Also called OLLAMA_MODELS

What
Models are stored as content-addressed blobs under ~/.ollama/models, or in the service user's home on Linux. OLLAMA_MODELS moves them to another disk.
Why
Large models fill a small system drive quickly; layers shared between variants are stored only once.
01 · Getting started with Ollama1 / 10