Ollama CLI Commands Every Beginner Should Know
Hey there, future-form digital builders! Ever wanted to harness the power of local AI models right from your terminal? Ollama makes it incredibly easy, and its Command Line Interface (CLI) is your gateway to managing and running these powerful tools without leaving your command prompt. Whether you’re a seasoned developer or just dipping your toes into the AI waters, this guide is for you. We’re going to break down the essential Ollama CLI commands you need to know to get started and become proficient.
What is the Ollama CLI, Anyway?
Think of the Ollama CLI as your personal assistant for all things Ollama. It’s a set of commands you type into your terminal to interact with the Ollama service that runs in the background. This means you can download models, chat with them, customize their behavior, and even connect them to other tools – all from one place. It’s the backbone of running LLMs locally and efficiently!
Getting Started: Installation and Verification
Before we dive into commands, let’s make sure Ollama is set up.
Installation:
- Linux: The quickest way is usually:
curl -fsSL https://ollama.com/install.sh | sh - macOS: Download the app from ollama.com, or use Homebrew:
brew install ollama. - Windows: Download and run the official installer from ollama.com.
- Linux: The quickest way is usually:
Verification: After installation, open your terminal and type:
ollama --versionIf you see a version number, you’re good to go! Running
ollamaby itself will often bring up an interactive menu to explore models and integrations.
The Core Commands: Model Management
Managing your AI models is a breeze with Ollama. Here are the commands you’ll use most often:
Listing Your Models: ollama list (or ollama ls)
Ever wonder what AI models you have downloaded and how much space they’re taking up? This command is your go-to.
$ ollama list
NAME ID SIZE MODIFIED
deepseek-r1:8b 6995872bfe4c 5.2 GB 2 weeks ago
gemma3:12b-it-qat 5d4fa005e7bb 8.9 GB 2 weeks ago
qwen3:14b bdbd181c33f2 9.3 GB 5 weeks ago
Downloading Models: ollama pull
Ready to try a new AI brain? Use pull to download models from the Ollama library.
ollama pull llama3.1:8b-instruct
This command will download the specified model. Be aware that models can be quite large, so keep an eye on your disk space!
Removing Models: ollama rm
Need to free up some space? rm lets you delete downloaded models.
ollama rm gemma3
Inspecting Models: ollama show
Want to know more about a model before you run it? show gives you the details.
ollama show llama3.1:8b-instruct
You can also get more specific info:
--modelfile: Shows the model’s recipe (FROM, SYSTEM, TEMPLATE, PARAMETER lines). Super useful before creating custom models!--parameters: Displays only the runtime parameters.--verbose: Provides extensive metadata.
Running Models: Your AI Companions
This is where the magic happens! You can chat with models or run single prompts.
Interactive Chat: ollama run
To start a conversation with a model, simply run it:
ollama run llama3.1:8b-instruct
This opens an interactive REPL (Read-Eval-Print Loop). You can type your questions, and the model will respond.
- Session Commands:
/bye: Ends the session./clear: Clears the conversation context./help: Shows available session commands.
One-Off Prompts
Need a quick answer without starting a full chat? Pass your prompt as a quoted string:
ollama run gemma3 "Explain what a cron job does in one paragraph."
This is great for scripting or quick lookups, as it prints the answer and exits.
Multiline Prompts
For longer inputs or structured data, wrap your text in triple quotes ("""):
>>> """
... Summarize this in one sentence:
... The quick brown fox jumps over the lazy dog.
... It happened on a Tuesday.
... """
Multimodal Models (Images)
Some models can understand images! Just add the image file path to your prompt:
ollama run gemma3 "Describe what is shown in this screenshot: /home/user/screenshot.png"
Customizing Model Behavior: The Modelfile
Want to tailor a model to a specific task or personality? A Modelfile is your blueprint. It lets you define a base model, system prompts, parameters, and prompt templates.
Example Modelfile (my-linux-admin-model.txt):
FROM gemma3
PARAMETER temperature 0.5
SYSTEM """You are a Linux server administration assistant. Answer only questions about Linux and server management."""
Creating and Running a Custom Model:
Create the Modelfile:
nano my-linux-admin-model.txt(Paste the content above and save)
Build the model:
ollama create linux-admin -f ./my-linux-admin-model.txtRun your custom model:
ollama run linux-adminNow,
linux-adminwill always act as your Linux assistant!
Ollama Server and Integrations
Running Ollama as a server and connecting it to other tools opens up a world of possibilities.
Starting the Server: ollama serve
This command starts the local Ollama API server, typically listening on http://localhost:11434. Most installations run this as a background service automatically, but you can start it manually if needed.
ollama serve
Running Models in Parallel: OLLAMA_NUM_PARALLEL
For heavier workloads, you might want to control how many requests Ollama handles at once. You can set the OLLAMA_NUM_PARALLEL environment variable before starting the server.
OLLAMA_NUM_PARALLEL=2 ollama serve
Experiment with this to tune performance!
Launching AI Coding Assistants: ollama launch
Ollama v0.15 introduced ollama launch for zero-config integration with AI coding tools.
- Interactive Menu: Just type
ollama launchto pick from a list of supported tools like Claude Code, Codex, or Droid. - Specific Tool:
ollama launch claude - With a specific model:
ollama launch claude --model qwen3-coder
This command sets up environment variables and points the tool to your local Ollama server, making local AI coding assistants a breeze.
Working with Files and Outputs
The CLI plays nicely with standard shell features:
Prompting with Files: Redirect a file’s content as input:
ollama run gemma3 "Summarize this server log:" < error.logSaving Responses: Redirect output to a file:
ollama run llama3.1:8b-instruct "List common security steps." > security-steps.txtUse
>>to append to a file.Generating Embeddings: Turn text into numerical vectors for search or RAG:
echo "What is a vector embedding?" | ollama run nomic-embed-text
Managing Running Models: ollama ps and ollama stop
Wondering which models are actively loaded in memory (especially in your GPU’s VRAM)?
Listing Running Models: ollama ps
ollama ps
This command shows you which models are loaded, their ID, size, and how long they’ll stay in memory (default is 4 minutes after the last request).
Stopping a Model: ollama stop
If you need to free up VRAM immediately, you can stop a model:
ollama stop llama3.1:8b-instruct
This unloads the model from memory but keeps it on disk.
Signing In and Cloud Models: ollama signin
For private models or those too large to run locally, you can sign in to your Ollama account:
ollama signin
This allows you to use cloud-hosted models seamlessly. Sign out with ollama signout.
FutureFormDigital’s Take: Power Up Your Workflow!
The Ollama CLI is an absolute game-changer for anyone looking to leverage local AI. From effortlessly downloading and running the latest models to crafting custom AI assistants with Modelfiles and integrating them into your coding workflow, it offers incredible flexibility and power.
Our Recommendation: Don’t be intimidated by the terminal! Start with ollama run and ollama list. Once you’re comfortable, experiment with ollama create and a simple Modelfile. The ability to automate tasks with file redirection and scripting is where the real productivity gains lie.
Frequently Asked Questions (FAQ)
Here are some common questions beginner users have about the Ollama CLI:
Q: What is Ollama CLI?
A: It’s the command-line interface for managing and running local AI models with Ollama.Q: How do I install Ollama?
A: Download the installer from ollama.com or usecurl -fsSL https://ollama.com/install.sh | shon Linux.Q: How do I download a model?
A: Use theollama pull <model_name>command.Q: How do I chat with a model?
A: Runollama run <model_name>to start an interactive session.Q: What if I want to ask a single question and exit?
A: Useollama run <model_name> "<your question>".Q: How do I free up GPU memory?
A: Useollama stop <model_name>to unload a model, orollama rm <model_name>to delete it entirely.Q: Can I make a model act like a specific assistant?
A: Yes, by creating a custom model using a Modelfile with a SYSTEM prompt.Q: How do I connect Ollama to coding tools?
A: Use theollama launchcommand.Q: Where are Ollama models stored?
A: By default, in your user’s home directory. You can find details and move them if needed.Q: What does
ollama psdo?
A: It shows which models are currently loaded into memory.
What’s your favorite Ollama CLI command, and how are you using it to build your resilient, independent digital workflows? Share your insights in the comments below!