Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
AI and LLM integration

The shell says ollama: command not found

Error/bin/bash: line 1: ollama: command not found

Short answer

The shell can only run ollama if the binary is installed in the same place the shell runs. Two cases cover almost every report: Ollama was never installed on that Linux machine, or it runs inside a Docker container and you typed the command on the host. Install it with the official script, or run the command through docker exec.

  • Applies to Ollama 0.x CLI, Ubuntu 24.04, Docker 27
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the shell where it looks for the command and whether a container is the thing that runs Ollama.

    command -v ollama || echo "not on PATH"
    docker ps --filter name=ollama
  2. 2Match what you see, then jump to its fix

    1. 1command -v prints nothing and docker ps shows no ollama containerOllama is not installed on this Linux machineFix
    2. 2docker ps lists an ollama container but the host shell has no ollama commandOllama runs in a Docker container, not on the hostFix

What does the error look like?

  • /bin/bash: line 1: ollama: command not found
  • command not found: ollama

Cause 1 of 2

Ollama is not installed on this Linux machine

1Check

No output from command -v means no binary is on PATH. A Linux server or a fresh VM starts without it.

command -v ollama
systemctl status ollama

2Fix

Run the install command from the Ollama Linux guide. It installs the binary and a systemd service.

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

3Verify

Open a new shell and print the version, then check the service.

ollama -v
sudo systemctl status ollama

Confirmed by docs.ollama.com

Did this fix it?

Cause 2 of 2

Ollama runs in a Docker container, not on the host

1Check

When you start Ollama from the ollama/ollama image, the CLI lives inside the container. The host has only the published port.

docker ps --filter name=ollama --format '{{.Names}} {{.Ports}}'

2Fix

Run the CLI inside the container with docker exec, using the container name from the run command.

docker exec -it ollama ollama run llama3.2
docker exec -it ollama ollama list

3Verify

The command runs and lists or starts a model.

docker exec -it ollama ollama -v

Confirmed by docs.ollama.com

Did this fix it?

How do I stop it coming back?

  • Decide once whether Ollama runs on the host or in Docker, and write the matching command in your README.
  • In scripts, call docker exec -i ollama ollama ... when the container is the install, so the script does not depend on the host PATH.
  • After install, check ollama -v in a new shell before you build anything on top of it.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

AI

Ollama is slow and the GPU is not being used

Replies arrive a few tokens per second on a machine with a GPU

Run ollama ps and read the PROCESSOR column: 100% GPU means the model is on the card, anything with CPU means it is not fully there.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.