Ollama CLI commands: the complete cheat sheet (with examples)

Every Ollama command you need, explained in plain English with real examples. Install and check, download and run, manage models, build a custom model with a Modelfile, call the REST API, and publish.

Two panels. On disk, the model store, holding the commands ollama pull, ollama list, ollama show, ollama cp and ollama rm. In memory, loaded and ready, holding ollama run, ollama ps, ollama stop, and a note that Ollama unloads a model by itself after about 5 idle minutes. A footer says stop clears memory only and rm deletes it from disk.
Fig. 1 — Most Ollama commands work on one of two places. Disk is where models are stored. Memory is where a model is loaded while you use it.

If Ollama is a video player for AI models (see What is Ollama?), then the command line is its remote control. A handful of short commands let you download models, chat with them, see what’s loaded, free up memory and disk, and even build your own customised model.

This is the complete cheat sheet: 23 commands in six groups, each with what it does, an example, and when you would use it. Example outputs are illustrative; your versions, IDs and sizes will differ.

Open a terminal to follow along: Command Prompt or PowerShell on Windows, Terminal on macOS or Linux.

The one idea that makes every command easy

Every model lives in one of two places:

  • On disk: downloaded and stored, until you delete it.
  • In memory: loaded into RAM or your GPU and ready to answer. Ollama unloads it by itself after a few idle minutes.

Look at the picture at the top of this page again. Each command either changes the disk, changes memory, or shows you one of them. Keep that in mind and the list below reads like common sense.

1. Install, start and check Ollama

1. Check the installed version

ollama --version

Shows the version of the Ollama CLI. This is the quickest way to confirm the install worked.

ollama version is 0.40.12

2. Start the local server

ollama serve

Starts the Ollama API server at localhost:11434. Every other command, app and program talks to this server.

3. Check the local API

curl http://localhost:11434/api/tags

Returns JSON describing the models available locally. If you get JSON back, the server is up and listening. (On Windows 10 and 11, curl is built in.)

2. Download and run models

4. Download a model

ollama pull qwen3.5:4b

Downloads the model without starting a chat. Use it to fetch a model ahead of time, for example before you go offline. Running pull again on a model you already have updates it if a newer version exists.

5. Run a model

ollama run qwen3.5:4b

Downloads the model if needed, loads it into memory, and opens an interactive chat in your terminal. This is the command you will use most. The first run looks like this:

pulling manifest
pulling 81fb60c7daa8: 100% ▕████████████████▏ 3.4 GB
verifying sha256 digest
writing manifest
success
>>> Explain RAG in one line
RAG looks up relevant facts first, then answers using them.
>>> /bye

After this, the model is on disk and in memory. The next run starts without downloading.

The same command works for other kinds of models too. For example, this community model generates images instead of text:

ollama run mannix/flux2-klein:4b

The name has a namespace/ in front because it was published by a user called mannix, not by Ollama itself. Image generation in Ollama is still experimental and depends on your operating system and Ollama version (it arrived on macOS first). Ollama’s official image models live under the x/ namespace, for example x/flux2-klein. Generated images are saved to the folder your terminal is in.

6. Ask a one-time question

ollama run qwen3.5:4b "Explain RAG with an example"

Sends one prompt straight from the command line, prints the answer, and exits. No chat session. Handy in scripts, or when you just want a quick answer.

7. Exit interactive chat

/bye

Type this inside the Ollama chat (at the >>> prompt) to leave and go back to your normal terminal. Typing /? inside the chat lists the other in-chat commands.

3. Manage downloaded models

8. List downloaded models

ollama list

Shows every model on your disk, with its ID, size and when it was last changed. This answers “what’s on my disk?”

NAME          ID              SIZE      MODIFIED
qwen3.5:4b    2a7d3c91f0e4    3.4 GB    2 minutes ago

9. Show running models

ollama ps

Shows the models loaded in memory right now, how much memory they use, whether they run on the CPU or GPU, and when they will unload by themselves. This answers “what’s in memory?”

NAME          SIZE      PROCESSOR    UNTIL
qwen3.5:4b    5.1 GB    100% GPU     4 minutes from now

Notice the size in memory (5.1 GB) is bigger than the download (3.4 GB). Memory also holds room for the conversation, which is why you need more free memory than the file size.

10. Inspect model information

ollama show qwen3.5:4b

Displays a model’s details: its architecture, number of parameters (weights), context length, capabilities such as vision, tools and thinking, default parameters, and the prompt template. Use it to check what a model can do before you build on it.

11. Display the Modelfile

ollama show --modelfile qwen3.5:4b

Displays the Modelfile: the small text recipe Ollama uses for this model (its base, template, system prompt and parameters). It is a great example to copy from when you write your own (see group 4 below).

Note: this is not the model weights file. It is only the configuration around it.

12. Stop a running model

ollama stop qwen3.5:4b

Unloads the model from memory straight away, instead of waiting for the idle timeout. The downloaded files stay on disk, so the next run starts without downloading. Use it to free RAM or GPU memory for something else.

13. Delete a model

ollama rm qwen3.5:4b

Removes the model from disk and frees the space (3.4 GB here). You can always pull it again later.

deleted 'qwen3.5:4b'

14. Copy a model name

ollama cp qwen3.5:4b my-tutor

Creates another name for the same model. Ollama stores models as layers and reuses them, so this usually takes almost no extra space. It is useful for giving a model a friendly name your app uses, so you can later point that name at a different model without changing code.

4. Create a custom model with a Modelfile

This is where it gets fun. You can take an existing model and give it a fixed personality and settings, then save that as a new model name.

A Modelfile with FROM qwen3.5:4b, SYSTEM You are a friendly Java tutor, and PARAMETER temperature 0.3, flows into ollama create java-tutor -f Modelfile, which produces a new local model called java-tutor that shares qwen3.5:4b's weights, then ollama run java-tutor. A note says this configures an existing model and does not train a new one.
A Modelfile is a recipe. ollama create turns it into a model name you can run.

Create a plain-text file named Modelfile (no extension) in your project folder:

FROM qwen3.5:4b
SYSTEM You are a friendly Java tutor. Explain concepts with examples and analogies.
PARAMETER temperature 0.3

Each line does one job:

  • FROM picks the base model to start from.
  • SYSTEM sets the model’s role and instructions. This becomes the system message for every chat. (The roles guide explains system messages in depth.)
  • PARAMETER configures how it generates text. temperature 0.3 makes answers more focused and consistent; higher values make them more varied and creative.

15. Create the custom model

ollama create java-tutor -f Modelfile

Builds a local model named java-tutor from the Modelfile. -f points to the file. It now shows up in ollama list.

16. Run the custom model

ollama run java-tutor

Starts chatting with your model, with the instructions already in place. Ask it “What is a HashMap?” and it answers like a friendly tutor, with an analogy, without you having to say so.

Note: this configures an existing model. It does not train a new one. The weights are exactly the same as qwen3.5:4b; only the instructions and settings around them change.

5. Use the Ollama REST API from the command line

Remember, Ollama is a server. You can talk to it directly with curl, the same way your code will. The REST API guide explains these in detail; here are the commands.

17. Generate text (REST API)

curl http://localhost:11434/api/generate -d "{\"model\":\"qwen3.5:4b\",\"prompt\":\"Explain RAG in simple terms\",\"stream\":false}"

Sends one prompt to /api/generate and returns one JSON response. The answer is in the response field.

18. Chat API

curl http://localhost:11434/api/chat -d "{\"model\":\"qwen3.5:4b\",\"messages\":[{\"role\":\"user\",\"content\":\"Explain MCP with an example\"}],\"stream\":false}"

Sends a list of chat messages, each with a role such as user or assistant, to /api/chat. The answer comes back in message.content. This is the endpoint chat apps and agents use.

19. Download an embedding model

ollama pull nomic-embed-text

Downloads a model designed to turn text into embeddings: lists of numbers that capture meaning. It does not chat; it measures meaning. (Our guide to tokens and embeddings explains what embeddings are.)

20. Generate an embedding

curl http://localhost:11434/api/embed -d "{\"model\":\"nomic-embed-text\",\"input\":\"Spring Boot is a Java framework\"}"

Returns a vector (a long list of numbers) representing the input text. Texts with similar meaning get similar vectors. You can store these in a vector database for semantic search and RAG, so your app can find the right paragraph and give it to the model.

6. Help and publishing

21. Show CLI help

ollama help

Lists every available command with a one-line description. Run this when you forget a command name.

22. Help for a command

ollama show --help

Displays the options for one command. Try ollama run --help or ollama create --help too; each shows its own flags.

23. Push a model

ollama push your-username/java-tutor

Publishes your model to your namespace on ollama.com so others can pull it. You need an Ollama account and to be signed in.

Note: replace your-username with your actual Ollama namespace. Before pushing, copy your local model to that name, for example ollama cp java-tutor your-username/java-tutor.

The cheat sheet on one screen

Command What it does Disk or memory?
ollama --version Show the installed version
ollama serve Start the server at localhost:11434
ollama pull <model> Download a model Disk
ollama run <model> Download if needed, load and chat Disk + memory
ollama run <model> "prompt" One question, then exit Disk + memory
/bye Leave the chat (inside the chat)
ollama list What’s on my disk? Shows disk
ollama ps What’s loaded right now? Shows memory
ollama show <model> Model details
ollama show --modelfile <model> The model’s Modelfile recipe
ollama stop <model> Unload from memory Memory
ollama rm <model> Delete from disk Disk
ollama cp <from> <to> A second name, same files Disk
ollama create <name> -f Modelfile Build a custom model Disk
ollama push <user>/<name> Publish to ollama.com
ollama help, <cmd> --help Help

The full series: Run LLMs locally with Ollama

Each part stands on its own, so jump to whichever you need:

  1. How to run an LLM on your own computer
  2. What is Ollama? The video player for AI models, and localhost:11434 explained
  3. Ollama CLI commands: the complete cheat sheet (you are here)
  4. The Ollama desktop app: chat, pick models, and launch Claude Code or Copilot
  5. System, user and assistant roles explained
  6. Ollama REST API: /api/generate vs /api/chat
  7. Call a local LLM from Python: a stateless request, then a chatbot with memory
  8. Call a local LLM from Java: HttpClient, a stateless request, then a chatbot with memory

See it in action

Prefer watching? This video walks through the same ideas with live, hands-on demos.

Video thumbnail: Ollama CLI commands: the complete cheat sheet (with examples)Watch on YouTube ↗

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.