This guide walks you through installing Ollama on Ubuntu and running your first local large language models. You’ll learn the quick install method, how to pull and run models, and how to interact with them via the command line and API. No prior experience with AI tools is required, just a terminal and an internet connection.
What You’ll Need
- Ubuntu 20.04 or newer (64-bit)
- At least 8 GB of RAM (16 GB or more recommended for larger models)
- An internet connection to download the installer and model files
- Basic familiarity with the terminal (opening a terminal, running commands)
Step-by-Step
- Open a terminal. Press
Ctrl+Alt+Tor search for “Terminal” in the applications menu. - Install Ollama using the official script. Run the following command and press Enter. This downloads and runs the installer, which sets up Ollama as a system service.
curl -fsSL https://ollama.com/install.sh | sh - Verify the installation. After the script finishes, check that Ollama is installed by running:
ollama --version
You should see output likeollama version 0.x.x. If not, close and reopen the terminal or log out and back in. - Pull a model. Ollama uses a library of open-source models. Start with a small, fast one like Llama 3.2 1B:
ollama pull llama3.2:1b
This downloads the model (about 1.3 GB). For a more capable model, tryollama pull llama3.2(about 4.9 GB) orollama pull mistral(about 4.1 GB). - Run the model interactively. Start a chat session with:
ollama run llama3.2:1b
You’ll see a>>>prompt. Type a question, like “What is the capital of France?” and press Enter. The model will respond. To exit, type/byeand press Enter. - Run a one-off prompt (non-interactive). You can also get a single response without entering the chat loop:
ollama run llama3.2:1b "Explain the water cycle in one sentence." - Use the REST API (optional). Ollama runs a local API server on port 11434. To test it, open a new terminal and run:
curl http://localhost:11434/api/generate -d '{"model": "llama3.2:1b", "prompt": "Hello!"}'
You’ll get a JSON response with the model’s output. - List and manage models. See what you have downloaded with
ollama list. Remove a model you no longer need withollama rm llama3.2:1b.
Common Mistakes
- Running out of memory. Large models (7B+ parameters) need significant RAM. If you get an error like “failed to load model” or the system freezes, try a smaller model or close other applications.
- Not enough disk space. Models are large (1-5 GB each). Check your free space with
df -hbefore pulling. - Using the wrong model name. The exact tag matters. Use
ollama listto see available models andollama show llama3.2:1bto get details. - Forgetting to restart the service after a manual install. If you install from source, you may need to start the service with
sudo systemctl start ollama.
Tips
- Start with a small model. For testing, use
llama3.2:1borphi3:mini; they’re fast and require less RAM. - Use the right model for the task. For coding, try
codellama; for general chat,llama3.2ormistral; for math,qwen2.5:7b. - Set the context length for long conversations. Use
ollama run llama3.2 --num-ctx 8192to increase the context window (default is 2048). - Keep Ollama updated. Run
ollama updateto get the latest version. - Use the API for automation. You can write scripts that call the local API, making it easy to integrate LLM responses into your workflows.
Troubleshooting
- “curl: command not found” – Install curl with
sudo apt install curland try the install command again. - “Permission denied” when running ollama – Add your user to the
ollamagroup:sudo usermod -aG ollama $USER, then log out and back in. - Model download is slow or fails – Check your internet connection. If you’re behind a proxy, set the
HTTP_PROXYandHTTPS_PROXYenvironment variables before running the install or pull. - “Error: model not found” – The model name may be incorrect. Run
ollama listto see what you have, or check the official library athttps://ollama.com/libraryfor the exact tag. - Ollama service is not running – Check with
systemctl status ollama. If it’s inactive, start it withsudo systemctl start ollama. - Out of memory errors – Reduce the number of concurrent requests, use a smaller model, or increase your swap space (not recommended for performance).
Frequently Asked Questions
Do I need a GPU to run Ollama?
No, Ollama works on CPU-only systems, but it will be slower. For better performance, an NVIDIA GPU with CUDA support is recommended. Ollama automatically uses the GPU if available.
How do I uninstall Ollama?
Run sudo systemctl stop ollama, then sudo rm /usr/local/bin/ollama and sudo rm -rf /usr/local/lib/ollama. Remove the service file with sudo rm /etc/systemd/system/ollama.service and reload systemd with sudo systemctl daemon-reload.
Can I use Ollama offline?
Yes, once a model is downloaded, you can use it without an internet connection. The API and CLI work entirely locally.
How do I update a model to a newer version?
Pull the same model again with ollama pull llama3.2:1b – Ollama will download the latest version if available.
Is it safe to run the install script?
The script is the official method recommended by Ollama. It installs the binary and sets up a systemd service. You can review the script first by opening it in a browser or using curl -fsSL https://ollama.com/install.sh | less before piping to sh.
Can I use Ollama with Python?
Yes, you can use the REST API with Python’s requests library. There’s also an official Python client package, but the API is straightforward for custom integrations.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Gmail Gemini Privacy: Data Access & Limit Settings
- Fix Outlook Inbox Corruption with DISM in Windows
- How to Set Up Apple Pay on iPhone
- How to Choose a Refurbished iPhone With Years of Support
- Voice Dictation in Google Docs: How to Use It
- Turn Off Message Notifications on Mac