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.
curl -fsSL https://ollama.com/install.sh | sh
ollama --version
systemctl status ollama
curl http://localhost:11434/api/versionollama 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.
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 --verboseChat 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,/clearand/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
pulldownloads or updates a model,listshows downloaded models and their sizes,rmdeletes one, andshowprints its architecture, parameters, context length, template and licence.- Why
- Models are gigabytes each; managing them keeps disks from filling up.
ollama pull gemma3:4b
ollama list
ollama show gemma3:4b
ollama show gemma3:4b --modelfile
ollama rm gemma3:4bps, stop and keep-alive
Also called keep_alive, OLLAMA_KEEP_ALIVE
- What
ollama pslists 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 stopunloads one now.- Why
- Loading a large model takes seconds, so keep it loaded while working and free memory when done.
ollama ps
ollama stop llama3.2
OLLAMA_KEEP_ALIVE=1h ollama serveThe server and OLLAMA_HOST
- What
ollama serveruns the server, normally started for you by the app or service.OLLAMA_HOSTsets its address,127.0.0.1:11434by 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.
OLLAMA_HOST=gpu-box.lan:11434 ollama list
OLLAMA_HOST=gpu-box.lan:11434 ollama run llama3.2Where 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_MODELSmoves them to another disk. - Why
- Large models fill a small system drive quickly; layers shared between variants are stored only once.