Barefoot AI HubTHE BAREFOOT FREELANCER
Start learning
▣ Local AI · Lesson 2 of 4

16Install & Master Ollama

Install Ollama on Mac, Windows, Linux or Docker, run your first model, and learn every command you'll use day to day — plus configuration, storage and troubleshooting.

⏱ 25 min📶 Beginner🧪 3-question check

What you'll learn

  • Install Ollama on your operating system
  • Download, run and manage models
  • Configure context length, model storage and network access
  • Troubleshoot the most common problems

Step 1 — Install

Download the app from ollama.com/download, unzip, and drag Ollama to Applications. Open it once — a llama icon appears in the menu bar and the ollama command becomes available. (Homebrew users: brew install ollama.)

terminalbash
ollama --version

Download OllamaSetup.exe from the Ollama download page and run it (no admin rights needed). Ollama runs in the system tray; NVIDIA and supported AMD GPUs are used automatically. Then open PowerShell:

powershellpowershell
ollama --version

The official script installs Ollama and registers it as a systemd service:

terminalbash
curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama     # should say "active (running)"

Ideal for servers. CPU only:

terminalbash
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
docker exec -it ollama ollama run gemma3:4b

NVIDIA GPU (after installing the NVIDIA Container Toolkit):

terminalbash
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Step 2 — Your first model

terminalbash
ollama run gemma3:4b

The first run downloads the model (a few GB), then drops you into a chat. Try: “Write three subject lines for a payment reminder email.” Type /bye to exit.

Inside the chatDoes
/?Help: list all chat commands
/set system <text>Set a system prompt for this session
/set parameter temperature 0.2Change a parameter on the fly
/show infoModel details: parameters, context length, quantization
"""Start/end a multi-line message (paste long text)
/byeExit

Step 3 — Every command you need

ollama cheat sheetbash
ollama run qwen3:8b              # download if needed + chat
ollama run qwen3:8b "Summarize: ..."   # one-shot answer, no chat session
ollama pull gemma3:12b            # download without running
ollama list                       # models on disk (+ size)
ollama ps                         # models loaded in memory right now (+ GPU/CPU split)
ollama show qwen3:8b              # details: parameters, context, license
ollama stop qwen3:8b              # unload from memory
ollama rm llama3.2:3b             # delete to free disk space
ollama cp qwen3:8b my-assistant   # copy/rename a model
ollama create name -f Modelfile   # build a custom model (next lesson)
ollama serve                      # start the server manually (port 11434)

Pipe files in with your shell: cat notes.txt | ollama run qwen3:8b "Turn these notes into action items".

Step 4 — Configuration that matters

Ollama is configured with environment variables. Set them before starting the server (on Mac/Windows, set them and restart the Ollama app).

VariableWhat it doesExample
OLLAMA_CONTEXT_LENGTHDefault context window for all models. Raise it for agents and long documents (uses more memory).16384 or 65536
OLLAMA_MODELSWhere models are stored — move them to a bigger drive./mnt/data/ollama
OLLAMA_HOSTAddress the server listens on. Default is local-only.0.0.0.0:11434 (LAN — see warning)
OLLAMA_KEEP_ALIVEHow long a model stays loaded after use.30m, -1 (forever)
OLLAMA_NUM_PARALLELParallel requests per model.2
terminalbash
launchctl setenv OLLAMA_CONTEXT_LENGTH 16384
# then quit and reopen the Ollama app
powershellpowershell
setx OLLAMA_CONTEXT_LENGTH 16384
# then quit Ollama from the tray and start it again
terminalbash
sudo systemctl edit ollama
# add under [Service]:
#   Environment="OLLAMA_CONTEXT_LENGTH=16384"
sudo systemctl restart ollama

Troubleshooting

ProblemFix
“could not connect to ollama”The server isn't running — open the Ollama app or run ollama serve.
Very slow responsesModel too big for your GPU/RAM. Check ollama ps: if it shows CPU instead of GPU, use a smaller model or lower context.
Out of memory / crashesUse a smaller model or a lower OLLAMA_CONTEXT_LENGTH; close other heavy apps.
Disk fullollama list then ollama rm unused models, or move storage with OLLAMA_MODELS.
Model forgets earlier parts of a long chat or documentContext window too small — raise context length for that model.
Tool calls failUse a model tagged for tools (e.g. qwen3, llama3.1) and keep tool descriptions clear.

Key takeaways

  • Install once, then `ollama run ` downloads and chats in one step.
  • Core commands: run, pull, list, ps, show, stop, rm, create, serve.
  • Raise OLLAMA_CONTEXT_LENGTH for agents and long docs; move storage with OLLAMA_MODELS.
  • Never expose port 11434 publicly — use Tailscale or an authenticated proxy.

Knowledge check

0 / 3

Q1Which command shows models currently loaded in memory?

Q2Default Ollama API port?

Q3Hermes needs a bigger context. What do you change?

Finished this lesson?Your progress is saved in this browser.