You're in luck! While Ollama doesn't come with a dedicated uninstall.sh script, it's relatively straightforward to remove its components. The installation script primarily sets up a systemd service and places the binary in a standard location.
Here's how to uninstall Ollama on Ubuntu:
Important Note: This process will delete all your downloaded models and any custom Ollama data. If you have fine-tuned models or custom content you want to preserve, back up the ~/.ollama directory before proceeding.
Step-by-Step Uninstallation
1. Stop and Disable the Ollama Service
First, you need to stop the running Ollama service and prevent it from starting automatically on boot.
sudo systemctl stop ollama
sudo systemctl disable ollama
2. Remove the Ollama Binary
The install.sh script typically places the ollama executable in /usr/local/bin/.
sudo rm /usr/local/bin/ollama
3. Remove Ollama Data and Models
This is the most important step for freeing up disk space, as all your downloaded models (like Llama 2, Mistral, etc.) are stored here. Ollama's default data directory is ~/.ollama.
rm -rf ~/.ollama
Warning: The rm -rf command permanently deletes files and directories without confirmation. Ensure you are in the correct directory and understand what you are deleting.
4. Clean up Systemd Service File
The installation script creates a systemd service unit file, usually at /etc/systemd/system/ollama.service. You should remove this.
sudo rm /etc/systemd/system/ollama.service
After removing the service file, tell systemd to reload its configuration so it's aware the service is gone:
sudo systemctl daemon-reload
5. Verify Uninstallation (Optional)
You can check if the service is gone and the binary is removed:
systemctl status ollama # Should report "could not be found" or similar
ollama --version # Should report "command not found"
ls -la ~/.ollama # Should report "No such file or directory"
Optional Cleanup (Less Common, but Good for Thoroughness)
-
Remove User from ollama Group (if created): The installer might add your user to a group like ollama (or video for GPU access). This is generally harmless to leave, but if you want to completely revert, you'd do:
# Replace <your_username> with your actual username
sudo gpasswd -d <your_username> ollama
You might need to log out and back in for group changes to take full effect.
-
Check for other Ollama related files: While the above covers the main components, if you've customized installation paths or have very specific setup, you might have other files elsewhere. However, for a standard curl | sh install, the above steps are usually sufficient.
After completing these steps, Ollama should be fully uninstalled from your Ubuntu machine.