Ollama is the quickest way to run open language models on your own computer, and almost everything you do with it happens through a short list of terminal commands. This page collects them in one place: managing models, chatting and scripting, the flags that change how a model runs, server settings, custom models and the local API. Keep it open next to your terminal. If you are installing Ollama for the first time, start with our Ollama tutorial for beginners and come back here.
Quick answer: the Ollama commands you will use most are ollama run <model> to chat (it downloads the model if needed), ollama pull to download, ollama ls to list installed models, ollama ps to see what is loaded and whether it is on the GPU, ollama stop to unload a model, ollama rm to delete one and ollama serve to start the server. Type ollama help for the full list on your version. |
Table of Contents
Ollama commands at a glance
How we compare: commands and defaults on this page are checked against Ollama’s official CLI reference and FAQ. Ollama changes quickly, so run ollama help <command> to confirm the options on your installed version.
| Command | What it does | Example |
|---|---|---|
ollama run | Chat with a model, or answer one prompt and exit | ollama run gemma4 |
ollama pull | Download or update a model | ollama pull qwen3 |
ollama ls / ollama list | List installed models and their sizes | ollama ls |
ollama ps | Show loaded models and CPU/GPU split | ollama ps |
ollama stop | Unload a running model from memory | ollama stop gemma4 |
ollama rm | Delete a model from disk | ollama rm qwen3 |
ollama show | Show a model’s details, parameters and licence | ollama show gemma4 |
ollama cp | Copy a model under a new name | ollama cp gemma4 my-gemma |
ollama create | Build a custom model from a Modelfile | ollama create mybot -f Modelfile |
ollama serve | Start the Ollama server manually | ollama serve |
ollama launch | Set up a coding app to use Ollama models | ollama launch |
ollama signin | Sign in to an Ollama account | ollama signin |

Running models and the most useful flags
Run ollama run <model> for an interactive chat, or add a prompt in quotes to get one answer and return to the shell, which is handy in scripts. You can pipe text in as well: cat notes.txt | ollama run gemma4 "Summarize this". For multimodal models, include an image path in the prompt. For multiple lines in the chat, wrap your text in triple quotes.
| Flag | Effect |
|---|---|
--verbose | Prints timing stats, including tokens per second, after each reply |
--format json | Forces the reply to be valid JSON |
--think / --hidethinking | Turns thinking on for reasoning models, or uses it but hides the trace |
--keepalive 10m | Keeps the model in memory for a set time after the last request |
--nowordwrap | Turns off word wrapping in the output |
Slash commands inside a chat
While chatting, /set parameter num_ctx 8192 raises the context window for the session, /set system "..." changes the system prompt, /show parameters or /show info displays settings, /save mymodel saves the session as a new local model and /bye exits. Type /? for the full list.
Inspecting a model with ollama show
ollama show <model> prints the architecture, parameter count, context length and quantization. Add --modelfile, --parameters, --system, --template or --license to print just that part. Check the licence before using a model commercially.
Managing memory with ollama ps and ollama stop
By default Ollama keeps a model in memory for five minutes after its last request, then unloads it. ollama ps shows what is loaded, and its PROCESSOR column tells you where: 100% GPU means the whole model is on the graphics card, 100% CPU means it is running from system memory, and a split such as 48%/52% CPU/GPU means it did not fully fit, which is the most common reason for slow replies. Use ollama stop to free memory immediately, or choose a smaller or more heavily quantized model. Our hardware guide explains how much memory each model size needs.

Server settings and environment variables
The Ollama server listens on 127.0.0.1:11434 by default, so only your own computer can reach it. Settings are changed with environment variables set before the server starts: on Windows and macOS, set them and restart the app; on Linux, add them to the systemd service with sudo systemctl edit ollama and restart it.
| Variable | What it controls | Default |
|---|---|---|
OLLAMA_HOST | Address and port the server binds to | 127.0.0.1:11434 |
OLLAMA_MODELS | Folder where models are stored | Your user folder under .ollama/models (Linux: /usr/share/ollama/.ollama/models) |
OLLAMA_CONTEXT_LENGTH | Default context window for all models | 4,096 tokens |
OLLAMA_KEEP_ALIVE | How long models stay loaded after use | 5 minutes |
OLLAMA_NUM_PARALLEL | Parallel requests each model handles | 1 |
OLLAMA_MAX_LOADED_MODELS | Models loaded at once, if they fit | 3 per GPU |
Raising the context length lets the model read longer documents but uses more memory, and the memory needed grows with the number of parallel requests too. Setting OLLAMA_HOST=0.0.0.0 exposes Ollama to your network; only do that on a trusted network, because the API has no password by default.
Custom models with a Modelfile
A Modelfile is a short text file that builds a customized model from an existing one. FROM names the base model, PARAMETER sets options such as num_ctx or temperature, and SYSTEM sets a permanent system prompt. Save it, run ollama create mybot -f Modelfile, then ollama run mybot. It is the easiest way to make a model that always answers in your team’s format with a longer context window.
Calling Ollama from code
Everything the command line does is also available through the local REST API at http://localhost:11434. Send chat requests to /api/chat, one-off prompts to /api/generate, and list models with /api/tags. Ollama also offers an OpenAI-compatible endpoint at /v1/chat/completions, so many apps and SDKs built for OpenAI can point at your local models by changing the base URL. That makes it easy to test a local model before paying for a hosted one; our best AI API guide compares the hosted options.
Fixing common Ollama problems
Slow replies: run ollama ps; if the model is split between CPU and GPU, use a smaller model or a lower-bit quantization. Out of memory or crashes: lower num_ctx or stop other loaded models. Port already in use: Ollama is probably already running in the background, so use it rather than starting a second ollama serve. Something else: check the server log. On Linux, run journalctl -u ollama; on macOS, the log is in ~/.ollama/logs/server.log; on Windows, look in %LOCALAPPDATA%\Ollama.

How one analyst scripted a daily summary
Illustrative example. Dario Esposito is a market analyst in Naples who reads dozens of supplier updates each morning. He installed Ollama, pulled a mid-sized model and checked with ollama ps that it ran 100% on his graphics card.
He wrote a Modelfile with a system prompt for his preferred summary format and a larger context window, created a custom model from it, and set up a scheduled script that pipes each day’s updates into ollama run. The summaries are ready when he starts work, and nothing leaves his laptop. For the bigger picture, see our local AI guide and our comparison of Ollama vs LM Studio.
Frequently Asked Questions
What are the basic Ollama commands?
The core Ollama commands are ollama run to chat with a model, ollama pull to download one, ollama ls to list installed models, ollama ps to see what is loaded, ollama stop to unload a model, ollama rm to delete one, ollama show for details and ollama serve to start the server.
What does ollama ps show?
It lists the models currently loaded in memory, their size, how long they will stay loaded and the PROCESSOR column. 100% GPU means the model fits entirely on the graphics card; a CPU/GPU split means part of it is in system memory, which slows replies.
How do I stop or unload a model in Ollama?
Run ollama stop followed by the model name to unload it from memory immediately. Otherwise Ollama unloads a model five minutes after its last request by default, which you can change with OLLAMA_KEEP_ALIVE or the –keepalive flag.
Where does Ollama store models?
On macOS and Windows, models are stored in the .ollama/models folder inside your user directory. On Linux the default is /usr/share/ollama/.ollama/models. Set the OLLAMA_MODELS environment variable to use a different folder, such as a larger drive.
How do I increase the context length in Ollama?
Inside a chat, use /set parameter num_ctx followed by the size. For every model, set OLLAMA_CONTEXT_LENGTH before starting the server, or add PARAMETER num_ctx to a Modelfile. The default is 4,096 tokens, and larger contexts need more memory.
Is there a GUI for Ollama?
Yes. Recent versions of Ollama include a desktop app on Windows and macOS for chatting with models, and many third-party interfaces connect to its local API. If you prefer a full graphical model browser, LM Studio is the main alternative.
Conclusion
A dozen Ollama commands cover almost everything: run, pull, ls, ps, stop, rm, show, create and serve, plus a few flags and environment variables. Learn ollama ps first, because it tells you whether a model actually fits on your GPU.
When the command line is not enough, the same features are available through the local API. Keep this cheat sheet open and check ollama help whenever you update.

