The shell says ollama: command not found
/bin/bash: line 1: ollama: command not foundShort 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.
Fix it fast
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=ollama2Match what you see, then jump to its fix
What does the error look like?
/bin/bash: line 1: ollama: command not foundcommand 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 ollama2Fix
Run the install command from the Ollama Linux guide. It installs the binary and a systemd service.
curl -fsSL https://ollama.com/install.sh | sh3Verify
Open a new shell and print the version, then check the service.
ollama -v
sudo systemctl status ollamaConfirmed by docs.ollama.com
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 list3Verify
The command runs and lists or starts a model.
docker exec -it ollama ollama -vConfirmed by docs.ollama.com
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 fixAI
Open WebUI or another Docker app cannot connect to Ollama
Connect call failed ('127.0.0.1', 11434)
Inside a container, localhost is the container itself, not your machine, so a call to 127.0.0.1:11434 never reaches Ollama.
3 causes, each with a fixAI
ollama Python library fails with httpx.ConnectError
httpx.ConnectError
httpx.ConnectError means the client could not open a connection to the address it used.
3 causes, each with a fixAI
Chroma data is empty after a restart in LangChain
The collection is empty after the app restarts
Chroma only keeps data when you ask it to.
3 causes, each with a fixServers
ping is missing inside a Docker container
sh: 1: ping: not found
Base images such as ubuntu are minimal, so ping is simply not installed.
2 causes, each with a fixServers
Running ps inside a container says command not found
bash: ps: command not found
Slim Debian and Ubuntu images do not ship the procps package, and ps comes from procps.
2 causes, each with a fix