Chatting with ollama run

Ollama · Essentials · 10 min

The terminal chat is the fastest way to try a model and check that everything works.

To chat with a model:

ollama run gemma4:e2b

The first time, Ollama downloads the model (several gigabytes), then opens an interactive chat with a >>> prompt. Type a message and press Enter. Model names in this course come from the official docs and will change over time; browse ollama.com/library for current ones.

Useful things inside the chat (type them at the >>> prompt):

  • /bye leaves the chat.
  • /clear forgets the conversation so far.
  • /set system You are a concise assistant. sets a system prompt.
  • /set parameter temperature 0.2 changes a setting for this session.
  • /show info shows details about the model.
  • /? lists all commands.
  • Wrap text in """ to type several lines.

One-shot prompts run a single question and exit, which is handy in scripts:

ollama run gemma4:e2b "Summarize what a Linux kernel is in one sentence."

You can also pipe a file in: cat notes.txt | ollama run gemma4:e2b "Summarize this:". For models that understand images, include an image file path in the prompt.

Flags worth knowing: --verbose prints speed statistics (tokens per second) after each answer, and --think turns on thinking mode for models that support it.

The desktop app on macOS and Windows offers the same chats in a window, with a model picker.

Example

ollama run gemma4:e2b                       # downloads once, then opens a chat
>>> /set system You answer in one short sentence.
>>> Why is the sky blue?
Sunlight scatters off air molecules, and blue light scatters the most.
>>> /bye

# One-shot prompt (prints the answer and exits)
ollama run gemma4:e2b "Give me three names for a cat."

# Pipe a file in, and show speed statistics
cat meeting.txt | ollama run gemma4:e2b --verbose "List the action items:"
# ... eval rate: 38.5 tokens/s

Remember

  • ollama run MODEL downloads if needed and opens a chat
  • In-chat: /bye, /clear, /set system, /set parameter, /?
  • ollama run MODEL "prompt" for one-shot use; --verbose shows speed

Watch out for

  • Assuming a model remembers earlier sessions; each new ollama run starts with an empty conversation.

Check yourself

  1. You want to test a model quickly from a shell script without an interactive chat. What do you use?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.ollama.com/cli