YouTip LogoYouTip

Ollama Commands

Ollama provides multiple command-line tools (CLI) for users to interact with locally running models. Basic format: ollama We can use ollama --help to see what commands are available: Large language model runner Usage: ollama ollama Available Commands: serve Start ollama create Create a model from a Modelfile show Show information for a model run Run a model stop Stop a running model pull Pull a model from a registry push Push a model to a registry list List models ps List running models cp Copy a model rm Remove a model help Help about any command Flags: -h, --help help for ollama -v, --version Show version information **1. Usage** * ollama : Run ollama with flags. * ollama : Run a specific command of ollama. **2. Available Commands** * serve: Start ollama service. * create: Create a model from a Modelfile. * show: Show detailed information for a model. * run: Run a model. * stop: Stop a running model. * pull: Pull a model from a registry. * push: Push a model to a registry. * list: List all models. * ps: List all running models. * cp: Copy a model. * rm: Remove a model. * help: Get help information about any command. **3. Flags** * -h, --help: Show help information for ollama. * -v, --version: Show version information. Complete Examples: | Command | Description | Example | | --- | --- | --- | | **`ollama run`** | **Run model**. Automatically pulls if not exists. | `ollama run llama3` | | **`ollama pull`** | **Pull model**. Downloads model from library but doesn't run. | `ollama pull mistral` | | **`ollama list`** | **List models**. Shows all locally downloaded models. | `ollama list` | | **`ollama rm`** | **Remove model**. Removes local model to free up space. | `ollama rm llama3` | | **`ollama cp`** | **Copy model**. Copies existing model with a new name (for testing). | `ollama cp llama3 my-model` | | **`ollama create`** | **Create model**. Creates custom model from Modelfile (advanced). | `ollama create my-bot -f ./Modelfile` | | **`ollama show`** | **Show information**. View model metadata, parameters, or Modelfile. | `ollama show --modelfile llama3` | | **`ollama ps`** | **View processes**. Shows currently running models and VRAM usage. | `ollama ps` | | **`ollama push`** | **Push model**. Upload your custom model to ollama.com. | `ollama push my-username/my-model` | | **`ollama serve`** | **Start service**. Start Ollama API service (usually runs automatically in background). | `ollama serve` | | **`ollama help`** | **Help**. View help information for any command. | `ollama help run` | * * * ### 1. Pulling and Removing Models **pull** Pull remote model to local. ollama pull **rm / remove** Remove local model. ollama rm **list / ls** List all local models. ollama list * * * ### 2. Running Models **run** Run model in interactive mode, without exiting. ollama run Can include system message and prompt: ollama run -s "" -p "" **run + script** Read prompt from file: ollama run < input.txt When you enter `ollama run` and enter the chat interface, you are no longer operating the command line, but having a conversation with AI. At this point, you can use shortcut commands starting with `/` to control the conversation: * **`/bye`** or **`/exit`**: **Most important!** Exit chat interface and return to command line. * **`/clear`**: Clear current context memory (start a new conversation). * **`/show info`**: View detailed parameter information of current model. * **`/set parameter seed 123`**: Set random seed (advanced usage, for reproducing results). * **`/help`**: View all available shortcuts in chat. * * * ### 3. Inference Interface (One-time Execution) **generate** Execute single inference, output text. ollama generate -p "" * * * ### 4. Creating and Modifying Models **create** Create local model using Modelfile. ollama create -f Modelfile **cp** Copy a model with a new name. ollama cp * * * ### 5. Server Related **start Ollama local service (default 11434). ollama serve **run serverless** When `ollama run` is executed, it automatically starts the backend service, no need to run separately. * * * ### 6. Model Information **show** View model metadata, parameters, template. ollama show * * * ### 7. Dedicated Parameters These parameters can mostly be used with run/generate: --num-predict Limit output token count--temperature Control randomness--top-k Sampling range--top-p Nucleus sampling--seed Fix randomness--format json Output JSON --keepalive Session keepalive time * * * ### 8. Modelfile Instructions Used when building models: * **FROM **: Base model * **SYSTEM "xxx"**: Set system prompt * **PARAMETER key=value**: Set default parameters * **TEMPLATE "xxx"**: Custom Chat template * **LICENSE "xxx"**: Set License * **ADAPTER ** / **WEIGHTS **: Load LoRA or additional weights * * * ### 9. API (When serve is running) REST endpoints (default http://localhost:11434/api): * `/api/generate`: Text generation * `/api/chat`: Chat streaming interface * `/api/pull`: Remote pull * `/api/tags`: Local model list Call example (curl): curl http://localhost:11434/api/generate -d '{"
← Ollama CliOllama Install β†’