How to Install Ollama on Ubuntu 26.04, 24.04 and 22.04

Install Ollama on Ubuntu 26.04, 24.04, and 22.04. Covers systemd, GitHub assets, model pulls, updates, and removal.

Last updatedAuthorJoshua JamesRead time9 minGuide typeUbuntu

Ollama turns an Ubuntu system into a local model runner for chat, coding helpers, embeddings, and API experiments, with local model runs staying on the machine by default. The most maintainable way to install Ollama on Ubuntu is the upstream Linux installer because it installs the current build, creates the systemd service, and keeps the local API bound to 127.0.0.1:11434 unless you change that setting yourself.

Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS use the same installer path and service layout. GitHub release assets and the Snapcraft package still matter when you compare sources, checksums, version pinning, or Snap preference, but they are not equal defaults for most Ubuntu installs.

Install Ollama on Ubuntu

Start with the small packages needed to download and extract the official Linux installer payload. The curl command retrieves the installer, while zstd handles the compressed Ollama release archive used by current Linux builds.

sudo apt update
sudo apt install curl ca-certificates zstd

If your account cannot run sudo, configure administrative access first with the Ubuntu sudoers setup guide, then return to the installation steps.

Ubuntu 26.04, 24.04, and 22.04 do not provide an APT package named ollama in the default repositories. Use the official Ollama Linux installer instead of trying sudo apt install ollama.

Download the installer to /tmp first. This two-step form is easier to inspect and rerun than piping the script directly into sh:

curl -fsSL https://ollama.com/install.sh -o /tmp/ollama-install.sh
sh /tmp/ollama-install.sh
rm -f /tmp/ollama-install.sh

The installer downloads the matching Linux release, installs Ollama under /usr/local, creates the ollama service account, adds service groups when available, writes /etc/systemd/system/ollama.service, and starts the service.

>>> Installing ollama to /usr/local
>>> Downloading ollama-linux-amd64.tar.zst
>>> Creating ollama user...
>>> Adding ollama user to render group...
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
>>> The Ollama API is now available at 127.0.0.1:11434.
>>> Install complete. Run "ollama" from the command line.
WARNING: No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode.

The CPU-only warning is normal on systems without detected NVIDIA or AMD acceleration. Ollama still installs correctly and uses CPU inference. If the installer detects supported GPU hardware, it can add GPU-specific payloads and, on some NVIDIA Ubuntu systems, attempt CUDA driver setup. Install and verify vendor drivers deliberately before relying on GPU acceleration.

Verify the Ollama Install

Confirm the binary path, systemd state, boot setting, local API endpoint, and client version:

command -v ollama
systemctl is-active ollama
systemctl is-enabled ollama
curl -fsS http://127.0.0.1:11434/api/version
ollama --version
/usr/local/bin/ollama
active
enabled
{"version":"0.30.5"}
ollama version is 0.30.5

Your version can be newer than the example output if Ollama has released another build. The important checks are the /usr/local/bin/ollama path, active service state, enabled boot setting, and a JSON response from the local API. If the API check fails immediately after installation, wait a few seconds and retry once before changing configuration.

Compare Ollama Install Sources

The official Linux download page and Ollama Linux documentation both point to the installer script as the normal Linux path. That script is the recommended Ubuntu method here because it owns the install layout, systemd service, service user, GPU package selection, and update behavior.

Source or assetUse it forUbuntu boundary
Official installerDefault Ubuntu install, service creation, updates, and removalInstalls under /usr/local and creates ollama.service
GitHub .tar.zst assetsChecksums, release notes, pinned assets, and custom packaging workflowsManual archive installs require you to own the service file, user, updates, and cleanup
Snapcraft packageSnap-preferring systems after checking publisher and channel freshnessThird-party package source, not the upstream-owned default path documented here

GitHub releases publish the same Linux payload family that the installer downloads. For Ubuntu workstations and servers, ollama-linux-amd64.tar.zst maps to x86_64 systems, ollama-linux-arm64.tar.zst maps to ARM64 or aarch64 systems, and ollama-linux-amd64-rocm.tar.zst is the AMD ROCm payload used when ROCm support applies. The release also includes sha256sum.txt for checksum verification.

If you are only checking the direct GitHub asset before choosing a packaging workflow, resolve the Ubuntu architecture and compare the asset against the release checksum file. This check downloads the selected archive, which can be larger than 1 GB on x86_64 systems:

arch=$(dpkg --print-architecture)

case "$arch" in
    amd64)
        asset="ollama-linux-amd64.tar.zst"
        ;;
    arm64)
        asset="ollama-linux-arm64.tar.zst"
        ;;
    *)
        asset=""
        echo "Unsupported architecture: $arch"
        ;;
esac

if [ -n "$asset" ]; then
    curl -fsSLO "https://github.com/ollama/ollama/releases/latest/download/$asset"
    curl -fsSLO "https://github.com/ollama/ollama/releases/latest/download/sha256sum.txt"
    checksum_line=$(grep " ./$asset$" sha256sum.txt)

    if printf '%s\n' "$checksum_line" | sha256sum -c -; then
        rm -f "$asset" sha256sum.txt
    fi
fi

The manual asset check does not replace the installer workflow. It helps confirm which archive and checksum belong to your architecture when you are auditing releases, building your own package, or avoiding a direct installer run for policy reasons.

The Snapcraft package is published by a third-party publisher rather than an upstream-owned Ollama account. Snap can still be convenient for users who intentionally prefer Snap packages, but check the channel and publisher before using it as your install source.

Get Started with Ollama

Ollama is installed once the service responds, but it does not include a downloaded model by default. Pull a small model first so you can test the CLI and API without a multi-gigabyte download. The Gemma 3 270M model is a practical first smoke test because it is much smaller than the default multi-billion-parameter tags.

ollama pull gemma3:270m
ollama list
NAME           ID              SIZE      MODIFIED
gemma3:270m    e7d36fb2c3b3    291 MB    Less than a second ago

Run the model from an interactive terminal when you want a local chat session:

ollama run gemma3:270m

For API testing, send a local request to the running service. The response is JSON and includes the generated text in the response field when stream is set to false.

curl -fsS http://127.0.0.1:11434/api/generate -d '{
  "model": "gemma3:270m",
  "prompt": "Reply with one short sentence.",
  "stream": false
}'

Use these model-management commands as your local library grows:

ollama list
ollama ps
ollama stop gemma3:270m
ollama rm gemma3:270m

ollama list shows downloaded models, ollama ps shows models currently loaded in memory, ollama stop unloads a running model, and ollama rm deletes a downloaded model from disk.

Manage the Ollama Service

The official installer starts Ollama as a systemd service named ollama. Check status, restart the service, or read recent logs with:

sudo systemctl status ollama --no-pager
sudo systemctl restart ollama
sudo journalctl -u ollama -n 50 --no-pager

Control the Ollama Listener

Ollama listens on 127.0.0.1:11434 by default, which keeps the API local to the Ubuntu machine. Change OLLAMA_HOST only when another host must reach the API, then protect the listener with a firewall, VPN, or reverse proxy. The Ubuntu UFW firewall guide covers LAN-only rules, and the Nginx reverse proxy guide covers proxy placement when you front the local API through a web server.

sudo install -d -m 0755 /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/listener.conf >/dev/null <<'EOF'
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
EOF
sudo systemctl daemon-reload
sudo systemctl restart ollama
systemctl is-active ollama

Use 0.0.0.0:11434 only when firewall or proxy controls are already in place. For a single-user workstation, keep the default loopback listener.

Configure Proxy or Custom CA Access

Corporate networks sometimes require outbound HTTPS proxy settings or a private root CA before Ollama can pull models. The service reads environment variables from systemd drop-ins, so keep proxy settings out of interactive shell profiles when the systemd service performs the download.

sudo install -d -m 0755 /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/proxy.conf >/dev/null <<'EOF'
[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:8443"
Environment="NO_PROXY=127.0.0.1,localhost"
EOF
sudo systemctl daemon-reload
sudo systemctl restart ollama

Replace the proxy URL with your network value. Avoid setting HTTP_PROXY for Ollama unless your environment specifically requires it, because model pulls use HTTPS and an HTTP proxy variable can interfere with local client connections. If the proxy requires credentials, use the credential handling your network team provides instead of leaving passwords in shared shell history or reusable snippets.

If your proxy uses an internal certificate authority, install the PEM or CRT file into Ubuntu’s trusted certificate store and restart Ollama:

sudo install -m 0644 /path/to/company-root-ca.crt /usr/local/share/ca-certificates/company-root-ca.crt
sudo update-ca-certificates
sudo systemctl restart ollama

Check or Move Model Storage

Linux service installs store models under /usr/share/ollama/.ollama/models by default. Check the current size before pulling larger models or cleaning storage with du disk usage commands:

sudo du -sh /usr/share/ollama/.ollama/models 2>/dev/null

Set OLLAMA_MODELS before pulling models if you want a dedicated storage path. The example uses /srv/ollama-models, but you can choose another mounted filesystem with enough free space.

sudo install -d -o ollama -g ollama -m 0755 /srv/ollama-models
sudo install -d -m 0755 /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/models.conf >/dev/null <<'EOF'
[Service]
Environment="OLLAMA_MODELS=/srv/ollama-models"
EOF
sudo systemctl daemon-reload
sudo systemctl restart ollama

If models already exist, copy or move them during a maintenance window and keep ownership with the ollama user. Do not point OLLAMA_MODELS at a directory owned only by your personal account.

Update Ollama on Ubuntu

Ollama’s upstream Linux documentation updates the script-based install by running the installer again. The script cleans the old /usr/local/lib/ollama payload, downloads the current release, restarts the service, and leaves downloaded models in place. Download a fresh copy, run it, remove the temporary script, and confirm the installed version:

curl -fsSL https://ollama.com/install.sh -o /tmp/ollama-install.sh
sh /tmp/ollama-install.sh
rm -f /tmp/ollama-install.sh

api_ready=0
for _attempt in {1..10}; do
    if api_version="$(curl -fsS http://127.0.0.1:11434/api/version 2>/dev/null)"; then
        printf 'API: %s\n' "$api_version"
        api_ready=1
        break
    fi
    sleep 2
done

if [ "$api_ready" -eq 0 ]; then
    echo "Ollama API did not become ready; check the service logs."
fi

ollama --version

Create an Optional update-ollama Helper

If you want one reusable command, create an optional update-ollama helper. The helper compares the installed version with the latest GitHub release, skips work when Ollama is already current, and runs the official installer only when an update is available. It is still a manual command, not an automatic background updater.

The setup block writes one file, /usr/local/bin/update-ollama. It refuses to replace symlinks, directories, or an existing file that lacks the article marker, so stop and inspect the path if one of those warnings appears.

(
set -euo pipefail

helper_path="/usr/local/bin/update-ollama"
helper_marker="# LinuxCapable Ollama update helper"

sudo install -d -m 0755 /usr/local/bin

if [ -L "$helper_path" ]; then
    echo "$helper_path is a symlink. Inspect it before replacing it."
    exit 1
fi

if [ -e "$helper_path" ] && [ ! -f "$helper_path" ]; then
    echo "$helper_path exists but is not a regular file."
    exit 1
fi

if [ -f "$helper_path" ] && ! sudo grep -qF "$helper_marker" "$helper_path"; then
    echo "$helper_path already exists and was not created by this article."
    exit 1
fi

sudo tee "$helper_path" >/dev/null <<'EOF'
#!/usr/bin/env bash
# LinuxCapable Ollama update helper
set -euo pipefail

if [ "$(id -u)" -ne 0 ]; then
    echo "Run this helper with sudo: sudo update-ollama"
    exit 1
fi

for required_cmd in awk curl mktemp tail; do
    if ! command -v "$required_cmd" >/dev/null 2>&1; then
        echo "Missing required command: $required_cmd"
        exit 1
    fi
done

if ! command -v ollama >/dev/null 2>&1; then
    echo "Ollama is not installed."
    exit 1
fi

installed="$(ollama --version | awk '/version is/ {print $NF; exit}')"
latest_url="$(curl -fsSL -o /dev/null -w '%{url_effective}' https://github.com/ollama/ollama/releases/latest)"
latest="${latest_url##*/}"
latest="${latest#v}"

if [ -z "$installed" ] || [ -z "$latest" ] || [ "$latest" = "latest" ]; then
    echo "Could not compare Ollama versions."
    exit 1
fi

printf 'Installed: %s\nLatest:    %s\n' "$installed" "$latest"

if [ "$installed" = "$latest" ]; then
    echo "Status: already current"
    exit 0
fi

echo "Status: update available"
echo "Running official Ollama installer..."

tmp_script="$(mktemp)"
install_log="$(mktemp)"
trap 'rm -f "$tmp_script" "$install_log"' EXIT

curl -fsSL https://ollama.com/install.sh -o "$tmp_script"

if sh "$tmp_script" >"$install_log" 2>&1; then
    echo "Installer: complete"
else
    echo "Ollama installer failed. Relevant output follows:"
    tail -n 40 "$install_log"
    exit 1
fi

api_ready=0
for _attempt in {1..10}; do
    if api_version="$(curl -fsS http://127.0.0.1:11434/api/version 2>/dev/null)"; then
        printf 'API: %s\n' "$api_version"
        api_ready=1
        break
    fi
    sleep 2
done

if [ "$api_ready" -eq 0 ]; then
    echo "Ollama API did not become ready after update."
    exit 1
fi

ollama --version
EOF

sudo chmod 0755 "$helper_path"
hash -r
command -v update-ollama
)
/usr/local/bin/update-ollama

The path output confirms that the shell can find the helper. Re-run the setup block only when you want to refresh the helper file itself; routine version checks use sudo update-ollama.

Run the helper with sudo when you want to check for a newer Ollama release and update only when needed. Root privileges are required because the official installer writes under /usr/local and restarts the systemd service.

sudo update-ollama

When an update is available, the status lines show the installed release, latest release, installer phase, API response, and final client version. Treat the version numbers as examples; the status line and final version are the important checks.

Installed: 0.30.4
Latest:    0.30.5
Status: update available
Running official Ollama installer...
Installer: complete
API: {"version":"0.30.5"}
ollama version is 0.30.5

An already-current system prints the same fields with a different status:

Installed: 0.30.5
Latest:    0.30.5
Status: already current

The helper refreshes the Ollama binary and systemd service only. Downloaded model tags are managed separately with ollama pull, so update model files only when you deliberately want the newer tag content.

If you need a specific version for testing or compatibility, choose a release from the Ollama GitHub releases page and pass it through OLLAMA_VERSION when running the downloaded installer. Replace the example version with the exact release you want.

curl -fsSL https://ollama.com/install.sh -o /tmp/ollama-install.sh
OLLAMA_VERSION=0.30.5 sh /tmp/ollama-install.sh
rm -f /tmp/ollama-install.sh

api_ready=0
for _attempt in {1..10}; do
    if api_version="$(curl -fsS http://127.0.0.1:11434/api/version 2>/dev/null)"; then
        printf 'API: %s\n' "$api_version"
        api_ready=1
        break
    fi
    sleep 2
done

if [ "$api_ready" -eq 0 ]; then
    echo "Ollama API did not become ready; check the service logs."
fi

ollama --version

Remove Ollama from Ubuntu

Remove the service, binaries, and optional helper first. The helper cleanup only deletes /usr/local/bin/update-ollama when the marker confirms it was created by the earlier article snippet.

sudo systemctl stop ollama
sudo systemctl disable ollama
sudo rm -f /etc/systemd/system/ollama.service
sudo rm -rf /etc/systemd/system/ollama.service.d
sudo systemctl daemon-reload
sudo rm -f /usr/local/bin/ollama
sudo rm -rf /usr/local/lib/ollama

if [ -f /usr/local/bin/update-ollama ] &&
    sudo grep -qF '# LinuxCapable Ollama update helper' /usr/local/bin/update-ollama; then
    sudo rm -f /usr/local/bin/update-ollama
fi

hash -r

The ollama.service.d removal line deletes optional listener, proxy, or model-storage overrides created earlier. Skip that line if you maintain separate local overrides that you want to inspect before deletion.

Downloaded models and the service account live separately. Run this block only when you also want to delete local model data under /usr/share/ollama:

sudo gpasswd -d "$USER" ollama 2>/dev/null || true
sudo gpasswd -d root ollama 2>/dev/null || true

if id ollama >/dev/null 2>&1; then
    sudo userdel ollama
fi

if getent group ollama >/dev/null 2>&1; then
    sudo groupdel ollama
fi

sudo rm -rf /usr/share/ollama

If the current terminal still shows your account in the ollama group, sign out and back in after removal. Supplemental group membership can remain attached to an existing login session until that session ends.

If you used the earlier /srv/ollama-models example for custom model storage, inspect that directory separately. It is outside the default /usr/share/ollama service home.

sudo du -sh /srv/ollama-models 2>/dev/null

Removing the custom model directory permanently deletes any models or files stored there. Back up anything you want to keep before running the cleanup command.

sudo rm -rf /srv/ollama-models

If you ran both cleanup blocks, verify the command, optional helper, service, user, and group state with:

command -v ollama || echo "ollama command removed"
command -v update-ollama || echo "update-ollama helper removed"
systemctl list-unit-files ollama.service --no-pager
id ollama 2>/dev/null || echo "ollama user removed"
getent group ollama || echo "ollama group removed"
ollama command removed
update-ollama helper removed
UNIT FILE STATE PRESET

0 unit files listed.
ollama user removed
ollama group removed

Troubleshoot Ollama on Ubuntu

Installer Cannot Find curl, CA Certificates, or zstd

If the installer cannot download files or extract the release archive, confirm that curl, CA certificates, and zstd are installed:

command -v curl
dpkg -s ca-certificates | grep '^Status:'
command -v zstd

If any check fails, reinstall the prerequisites and rerun the Ollama installer:

sudo apt update
sudo apt install curl ca-certificates zstd

Ollama API Does Not Respond

If the local API does not respond, check the service state and logs before changing model commands:

systemctl is-active ollama
sudo journalctl -u ollama -n 80 --no-pager

Restart the service and retest the loopback endpoint:

sudo systemctl restart ollama
curl -fsS http://127.0.0.1:11434/api/version

Port 11434 Is Already in Use

If another process already owns the Ollama port, identify the listener:

sudo ss -ltnp 'sport = :11434'

Stop the conflicting service or choose a different OLLAMA_HOST port in the systemd override. Restart Ollama after changing the listener.

GPU Warning or CPU-Only Mode Appears

If GPU acceleration is missing, start with the vendor driver. NVIDIA systems should return GPU details from nvidia-smi; if they do not, install the packaged driver first with the Ubuntu NVIDIA driver guide. AMD ROCm support depends on supported hardware, ROCm packages, and the extra ROCm payload described in the Ollama Linux documentation.

Model Downloads Fail Behind a Proxy or Custom CA

If model pulls fail only on a corporate network, put HTTPS proxy settings in the Ollama systemd drop-in and restart the service. For certificate errors, install the internal root CA with update-ca-certificates, then retry the model pull.

sudo systemctl restart ollama
ollama pull gemma3:270m

Models Use Too Much Disk Space

If model downloads fill more disk than expected, check the service user’s model directory and remove unused models first:

sudo du -sh /usr/share/ollama/.ollama/models 2>/dev/null
ollama list
ollama rm model-name

Use OLLAMA_MODELS for future storage placement instead of deleting the service account just to reclaim one model. Keep full removal for systems where you no longer need Ollama or its downloaded model data.

Conclusion

Ollama is ready once the service exists, the API responds on 127.0.0.1:11434, and one model appears in ollama list. Use the upstream installer for updates, keep Snap as a deliberate third-party choice, and use GitHub releases for checksums, changelogs, or pinned assets. For terminal AI workflows, install Codex CLI on Ubuntu, Gemini CLI on Ubuntu, or Claude Code on Ubuntu.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: