# Ollama CLI commands: ollama ps, run, pull and more

> Every Ollama CLI command with examples: ps, run, pull, show, create, stop and rm, plus server environment variables and the matching REST API calls.

This page is a reference for the `ollama` command line tool on a Linux server. It lists every command, the flags that matter in practice, the environment variables of the background service and the REST API calls that do the same work over HTTP. The commands and flags were checked against the Ollama source code and documentation for release v0.40.14.

If Ollama is not installed yet, follow [how to run Ollama on a CPU only VPS](https://datapasa.com/wiki/guides/run-ollama-on-cpu-vps) first. The examples below use the small `gemma3:1b` model. Replace it with any model name from the Ollama library.

## All commands at a glance

| Command | What it does |
|---|---|
| `ollama serve` | Start the Ollama server in the foreground (alias `ollama start`) |
| `ollama run MODEL [PROMPT]` | Chat with a model, or answer one prompt and exit |
| `ollama pull MODEL` | Download a model or update it to the latest version |
| `ollama push MODEL` | Upload your own model to ollama.com |
| `ollama list` / `ollama ls` | Show models stored on disk |
| `ollama ps` | Show models currently loaded in memory |
| `ollama stop MODEL` | Unload a running model from memory |
| `ollama show MODEL` | Print model details, parameters, template or license |
| `ollama create NAME -f Modelfile` | Build a custom model from a Modelfile |
| `ollama cp SOURCE DESTINATION` | Copy a model under a new name |
| `ollama rm MODEL [MODEL...]` | Delete one or more models from disk |
| `ollama signin` / `ollama signout` | Connect or disconnect the server from an ollama.com account (aliases `login`, `logout`) |
| `ollama launch` | Configure a coding tool such as Claude Code, Codex or OpenCode to use Ollama |
| `ollama -v` | Print the client and server version |

Every command accepts `--help`, for example `ollama run --help`. The CLI is a client: apart from `serve`, each command talks to the server on `127.0.0.1:11434`, so the `ollama` service must be running.

## ollama run

Start an interactive chat. The model is downloaded first if it is not on disk yet:

```bash
ollama run gemma3:1b
```

Pass a prompt to get one answer and return to the shell. This form works in scripts and cron jobs:

```bash
ollama run gemma3:1b "Summarize the benefits of NVMe storage in two sentences."
```

Text from a pipe is added to the prompt, which is handy for log files and documents:

```bash
cat /var/log/nginx/error.log | tail -n 50 | ollama run gemma3:1b "Explain these errors briefly:"
```

Flags of `ollama run` that are useful on a server:

| Flag | Effect |
|---|---|
| `--verbose` | After each answer, print timings: load time, prompt evaluation rate and generation speed in tokens per second |
| `--format json` | Force the answer to be valid JSON |
| `--keepalive 30m` | Keep the model in memory for this long after the last request, instead of the server default |
| `--nowordwrap` | Do not wrap long lines, useful when the output goes to a file |
| `--think` / `--think=false` | Turn the reasoning phase on or off for models that support it (`high`, `medium` and `low` work on some models) |
| `--hidethinking` | Keep reasoning on but print only the final answer |
| `--insecure` | Allow pulling from a registry without valid TLS |

`--verbose` is the quickest benchmark you have. The `eval rate` line shows how many tokens per second the model generates on your CPU:

```bash
ollama run gemma3:1b --verbose "Write a haiku about servers."
```

A JSON example for scripts:

```bash
ollama run gemma3:1b --format json "List three Linux distributions as a JSON array named distros."
```

### Commands inside the chat

At the `>>>` prompt these commands are available:

| Command | Effect |
|---|---|
| `/?` or `/help` | List all chat commands |
| `/set parameter num_ctx 8192` | Change a parameter for this session, here the context length |
| `/set system "You are a terse assistant."` | Set a system message |
| `/set verbose` | Show timings after every answer |
| `/show info` | Print model details |
| `/clear` | Clear the conversation context |
| `/save NAME` | Save the current session as a new model |
| `/load NAME` | Switch to another model |
| `/bye` | Exit |

Wrap text in `"""` to type a prompt that spans several lines.

## ollama pull, list, cp and rm

Download a model without starting it:

```bash
ollama pull gemma3:1b
```

Running `pull` again on a model you already have updates it. Only the changed layers are downloaded.

List what is stored on disk:

```bash
ollama list
```

The table has four columns: `NAME` (model and tag), `ID` (the first 12 characters of the digest), `SIZE` (space on disk) and `MODIFIED` (when it was pulled or created). `ollama ls` is the same command.

Copy a model under another name. No data is duplicated, both names point to the same files:

```bash
ollama cp gemma3:1b my-assistant
```

Delete models. You can pass several names at once, and a model that is loaded is stopped first:

```bash
ollama rm my-assistant gemma3:1b
```

## ollama ps

`ollama ps` lists the models that are loaded in memory right now. A model that is only on disk does not appear here. On a CPU server the output looks like this:

```
NAME         ID              SIZE      PROCESSOR    CONTEXT    RUNNER    UNTIL
gemma3:1b    97558784bdc9    1.9 GB    100% CPU     4096       ggml      4 minutes from now
```

The numbers on your server will differ with the model, the context length and the Ollama version. What each column means:

| Column | Meaning |
|---|---|
| `NAME` | The model and tag that is loaded |
| `ID` | Short digest, the same as in `ollama list` |
| `SIZE` | Memory the loaded model takes, including the context cache. This is usually larger than the size on disk |
| `PROCESSOR` | Where the model lives: `100% CPU` means fully in system RAM, `100% GPU` means fully in video memory, and a split like `48%/52% CPU/GPU` means it is divided |
| `CONTEXT` | Context length in tokens that the model was loaded with |
| `RUNNER` | The inference engine that serves the model, for example `ggml` or `llamacpp` |
| `UNTIL` | When the model will be unloaded if no new requests arrive. `Forever` means it never expires, `Stopping...` means it is being unloaded |

Older Ollama versions print only `NAME`, `ID`, `SIZE`, `PROCESSOR` and `UNTIL`. To see a single model, add part of its name: `ollama ps gemma3`.

On a DataPasa VPS there is no GPU, so `PROCESSOR` always shows `100% CPU`. That is expected and not an error.

## ollama stop

Unload a model right away and free its memory. The files stay on disk:

```bash
ollama stop gemma3:1b
```

The next request loads the model again, which takes a few seconds on a CPU.

## ollama show

Print a summary of a model: architecture, parameter count, context length, quantization, capabilities and default parameters.

```bash
ollama show gemma3:1b
```

Flags print one part only:

| Flag | Prints |
|---|---|
| `--modelfile` | The full Modelfile, a good starting point for your own model |
| `--parameters` | Default parameters such as `temperature`, `top_k` and stop tokens |
| `--template` | The prompt template |
| `--system` | The built in system message, if there is one |
| `--license` | The license text |
| `-v`, `--verbose` | Detailed metadata of the model file |

## ollama create with a Modelfile

A Modelfile describes a new model on top of an existing one: a fixed system prompt, different defaults, a longer context. Create a working folder and a file named `Modelfile`:

```bash
mkdir -p ~/models/support-bot && cd ~/models/support-bot
nano Modelfile
```

```
FROM gemma3:1b
PARAMETER temperature 0.3
PARAMETER num_ctx 8192
SYSTEM """
You answer customer questions about web hosting. Keep answers short and polite.
"""
```

Build and run it:

```bash
ollama create support-bot -f Modelfile
ollama run support-bot
```

Common Modelfile instructions:

| Instruction | Purpose |
|---|---|
| `FROM` | Base model name, or a path to a GGUF or Safetensors file |
| `PARAMETER` | Default option, for example `temperature`, `num_ctx`, `top_p`, `stop` |
| `SYSTEM` | System message used for every chat |
| `TEMPLATE` | Prompt template, only needed for imported models |
| `ADAPTER` | A LoRA adapter to apply on top of the base model |
| `MESSAGE` | Example dialogue to prime the model |
| `LICENSE` | License text stored with the model |

The new model shares layers with its base, so it takes almost no extra disk space. `ollama create -q` can quantize a model while importing it from Safetensors weights.

## ollama push, signin and launch

To publish a model on ollama.com, create an account, run `ollama signin` on the server and follow the link it prints. Then copy the model into your namespace and push it:

```bash
ollama cp support-bot YOUR_USERNAME/support-bot
ollama push YOUR_USERNAME/support-bot
```

`ollama signout` disconnects the server from the account. `ollama launch` sets up a coding assistant such as Claude Code, Codex, OpenCode or Droid to use your Ollama models. It is aimed at desktops and is rarely needed on a server.

## ollama serve and server settings

With the official installer the server already runs as the `ollama` systemd service, so you do not start `ollama serve` yourself. Run it in the foreground only for debugging, after stopping the service:

```bash
systemctl stop ollama
OLLAMA_DEBUG=1 ollama serve
```

The server is configured with environment variables. These are the ones that matter on a VPS:

| Variable | Default | What it controls |
|---|---|---|
| `OLLAMA_HOST` | `127.0.0.1:11434` | Address and port the API listens on |
| `OLLAMA_KEEP_ALIVE` | `5m` | How long an idle model stays in memory. `0` unloads at once, a negative value such as `-1` keeps it loaded |
| `OLLAMA_MODELS` | `/usr/share/ollama/.ollama/models` | Folder where models are stored |
| `OLLAMA_NUM_PARALLEL` | `1` | How many requests one model processes at the same time |
| `OLLAMA_MAX_LOADED_MODELS` | `3` without a GPU | How many different models can be in memory at once |
| `OLLAMA_MAX_QUEUE` | `512` | Requests that may wait before the server answers with HTTP 503 |
| `OLLAMA_CONTEXT_LENGTH` | `4096` without a GPU | Default context length when a request does not set one |
| `OLLAMA_ORIGINS` | local origins | Extra browser origins allowed to call the API |
| `OLLAMA_DEBUG` | off | Verbose logging, set to `1` |

`ollama serve --help` prints the full list for your version.

### Set variables with a systemd override

Do not edit the unit file the installer created, because an update overwrites it. Use an override instead:

```bash
systemctl edit ollama.service
```

Add the variables under `[Service]`, one `Environment` line each:

```
[Service]
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_MAX_LOADED_MODELS=1"
Environment="OLLAMA_NUM_PARALLEL=1"
```

Apply and check:

```bash
systemctl daemon-reload
systemctl restart ollama
systemctl show ollama --property=Environment
```

If you move models with `OLLAMA_MODELS`, the new folder must belong to the `ollama` user, for example `chown -R ollama:ollama /data/ollama`.

## REST API equivalents

Everything the CLI does goes through the HTTP API on port 11434. You can call it with curl from the server or from apps running on it.

| CLI | API call |
|---|---|
| `ollama run` (one prompt) | `POST /api/generate` |
| `ollama run` (chat) | `POST /api/chat` |
| `ollama list` | `GET /api/tags` |
| `ollama ps` | `GET /api/ps` |
| `ollama show` | `POST /api/show` |
| `ollama pull` | `POST /api/pull` |
| `ollama cp` | `POST /api/copy` |
| `ollama rm` | `DELETE /api/delete` |
| `ollama stop` | `POST /api/generate` with `"keep_alive": 0` |
| `ollama -v` | `GET /api/version` |

Generate a single answer. `"stream": false` returns one JSON object instead of a stream of chunks:

```bash
curl http://localhost:11434/api/generate -d '{
  "model": "gemma3:1b",
  "prompt": "Name three uses of a VPS.",
  "stream": false
}'
```

A chat with history and a system message:

```bash
curl http://localhost:11434/api/chat -d '{
  "model": "gemma3:1b",
  "messages": [
    { "role": "system", "content": "Answer in one sentence." },
    { "role": "user", "content": "What is KVM virtualization?" }
  ],
  "stream": false,
  "options": { "temperature": 0.2, "num_ctx": 4096 }
}'
```

List downloaded and loaded models:

```bash
curl http://localhost:11434/api/tags
curl http://localhost:11434/api/ps
```

`/api/ps` returns the same data as `ollama ps` in JSON: `size` is the memory in bytes, `size_vram` is the part in video memory (always `0` on a CPU server), `context_length` and `expires_at` match the CONTEXT and UNTIL columns.

Load a model in advance, or unload it, by sending a request with no prompt:

```bash
curl http://localhost:11434/api/generate -d '{"model": "gemma3:1b", "keep_alive": -1}'
curl http://localhost:11434/api/generate -d '{"model": "gemma3:1b", "keep_alive": 0}'
```

The first keeps the model in memory until the service restarts, the second unloads it at once.

## Reading ollama ps on a CPU VPS

On a server without a GPU, models are loaded into the same RAM that the system and your other apps use. A few habits keep memory under control:

- **Compare `SIZE` with free memory.** Run `ollama ps` and `free -h` side by side. The model `SIZE` must fit in available RAM with room left for the system. Our guide on [how much RAM your VPS needs](https://datapasa.com/wiki/getting-started/how-much-ram-does-my-vps-need) helps with sizing.
- **Watch the context.** A bigger `CONTEXT` means a bigger `SIZE`. Memory for the context also grows with `OLLAMA_NUM_PARALLEL`, because each parallel slot gets its own cache. On 4 to 8 GB plans keep parallel requests at `1`.
- **Allow one model at a time on small plans.** With the default of three loaded models, a request to a second model can push the first one into swap or make the kernel kill the process. `OLLAMA_MAX_LOADED_MODELS=1` makes Ollama unload the old model before loading a new one.
- **Unload when you are done.** `ollama stop MODEL` frees memory immediately. If a model is used rarely, a short `OLLAMA_KEEP_ALIVE` such as `2m` returns RAM quickly. If it is used all the time, a long keep alive saves the reload delay on every request.
- **Check the logs when a model fails to load.** `journalctl -u ollama -n 100` shows memory errors and load times.

As a guide, 1B to 4B models fit on VPS-3 (2 vCPU, 4 GB) and VPS-4 (4 vCPU, 8 GB), and 12B to 14B models need VPS-6 (6 vCPU, 16 GB). DataPasa servers run on NVMe in Falkenstein, Germany, and are billed by the hour from a prepaid balance, so you can test a larger plan for a day and delete it. Plans for language models are on the [Ollama VPS](https://datapasa.com/en/ollama-vps) page and all prices are on the [pricing](https://datapasa.com/en/pricing) page.

> **Never expose port 11434 to the internet.** The Ollama API has no authentication. Anyone who reaches it can run your models, pull new ones to fill your disk and delete the ones you have. Keep `OLLAMA_HOST` on `127.0.0.1` and reach the API through an SSH tunnel or a reverse proxy with a password, as shown in the [Ollama setup guide](https://datapasa.com/wiki/guides/run-ollama-on-cpu-vps). If you ever change `OLLAMA_HOST` to `0.0.0.0`, block the port with a firewall, see [how to secure your VPS with UFW and Fail2ban](https://datapasa.com/wiki/server-management/secure-vps-ufw-fail2ban).

## Summary

`ollama run`, `pull`, `list` and `rm` cover daily work with models, `ollama ps` and `ollama stop` show and free the memory they use, and `ollama show` and `ollama create` let you inspect and customize them. Server behavior is set with environment variables in a systemd override, and every command has a REST API counterpart on localhost. To run these models around the clock, pick a plan on the [Ollama VPS](https://datapasa.com/en/ollama-vps) page.
