SQLite is a lightweight, file-based database engine trusted by developers, system administrators, and embedded device makers for its simplicity and reliability. Unlike traditional client-server databases, SQLite requires no separate service—each database is a single file, making it ideal for local development, scripting, and applications where minimal setup is essential.
This guide shows you how to install SQLite 3 on Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. You can use the stable sqlite3 package from Ubuntu’s repositories for most needs, or compile the latest version from source if you require the newest features. Both methods are covered below, so you can choose the best fit for your workflow.
Install SQLite 3 on Ubuntu
Choose Your SQLite 3 Installation Method on Ubuntu
Start with APT unless you need features newer than your Ubuntu release provides. Source compilation gives you the latest branch, but you manage updates manually.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| APT (Recommended) | Ubuntu default repositories | Distribution default | Automatic through standard APT upgrades | Most users needing stable packages |
| Source Compilation | Official SQLite source archive | Latest upstream release | Manual recompilation | Developers needing newest features quickly |
Default SQLite 3 Versions by Ubuntu Release
Ubuntu packages different SQLite branches by LTS release. Use this table when version-specific behavior matters for your application stack.
| Ubuntu Release | Default SQLite | Ubuntu Support Window | Best For |
|---|---|---|---|
| Ubuntu 26.04 LTS | SQLite 3.46.x | Standard support through April 2031 | New deployments on the current LTS |
| Ubuntu 24.04 LTS | SQLite 3.45.x | Standard support through April 2029 | Stable production systems |
| Ubuntu 22.04 LTS | SQLite 3.37.x | Standard support through April 2027 | Legacy compatibility requirements |
These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. Repository installs follow each release’s packaged SQLite branch, while source compilation builds the latest upstream version. The command flow below stays consistent across supported LTS releases.
Update Ubuntu Before Installing SQLite 3
Refresh package metadata and apply pending upgrades before installation to avoid dependency conflicts.
sudo apt update && sudo apt upgrade
This guide uses
sudofor system-level package and install commands. If your account does not have sudo access yet, follow our guide on how to add a new user to sudoers on Ubuntu.
You should see package indexes refresh successfully:
Hit:1 http://archive.ubuntu.com/ubuntu resolute InRelease Hit:2 http://security.ubuntu.com/ubuntu resolute-security InRelease Reading package lists... Done Building dependency tree... Done Reading state information... Done
Method 1: Install SQLite 3 with APT on Ubuntu
To install SQLite 3 on Ubuntu with APT, run the command below. This method gives you predictable updates with minimal maintenance overhead.
sudo apt install sqlite3
The sqlite3 package installs the command-line shell and pulls in libsqlite3-0 for runtime library support.
Verify SQLite 3 APT Installation on Ubuntu
sqlite3 --version
Example output on Ubuntu 26.04:
3.46.1 2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69aalt1 (64-bit)
The version branch should align with your release: Ubuntu 26.04 returns 3.46.x, Ubuntu 24.04 returns 3.45.x, and Ubuntu 22.04 returns 3.37.x.
Method 2: Compile SQLite 3 from Source on Ubuntu
Compile from source when you need the latest SQLite release instead of the branch shipped by your Ubuntu LTS.
Install Build Dependencies for SQLite Source Compilation on Ubuntu
sudo apt install build-essential curl
This installs GCC, make, and related build tools, plus curl for release detection and source downloads.
If these command filters are new to you, review our curl command guide and grep command guide before continuing.
Download the Latest SQLite 3 Source Archive on Ubuntu
Create a dedicated build directory, detect the latest version from the official SQLite GitHub mirror, then download the matching autoconf tarball from sqlite.org.
mkdir -p ~/sqlite-build && cd ~/sqlite-build
SQLITE_VERSION=$(curl -fsSL https://api.github.com/repos/sqlite/sqlite/tags?per_page=20 | grep -oE '"name": "version-[0-9]+\.[0-9]+\.[0-9]+"' | head -n 1 | sed -E 's/.*version-([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
VERSION_NUM=$(echo "$SQLITE_VERSION" | awk -F. '{printf "%d%02d%02d00", $1, $2, $3}')
YEAR=$(date +%Y)
echo "Latest SQLite release: $SQLITE_VERSION"
echo "Archive id: $VERSION_NUM"
curl -fLO --progress-bar "https://www.sqlite.org/${YEAR}/sqlite-autoconf-${VERSION_NUM}.tar.gz" || curl -fLO --progress-bar "https://www.sqlite.org/$((YEAR-1))/sqlite-autoconf-${VERSION_NUM}.tar.gz"
Example output:
Latest SQLite release: 3.51.2 Archive id: 3510200 ######################################################################## 100.0%
If GitHub API requests are rate-limited in your environment, open the SQLite download page, copy the latest autoconf archive id, and rerun this section with manual values.
Extract and Configure SQLite Source on Ubuntu
tar -xzf "sqlite-autoconf-${VERSION_NUM}.tar.gz"
cd "sqlite-autoconf-${VERSION_NUM}"
./configure --prefix=/usr/local
Using --prefix=/usr/local keeps source-built files separate from APT-managed files in /usr, which reduces upgrade and removal conflicts.
Expected configure output includes:
Configuring SQLite version 3.51.2 Host System...x86_64-pc-linux-gnu Created Makefile from Makefile.in Created sqlite3.pc from sqlite3.pc.in Created sqlite_cfg.h
Compile and Install SQLite 3 Source Build on Ubuntu
make -j"$(nproc)"
sudo make install
Expected install output includes file deployment to /usr/local:
/usr/bin/install libsqlite3.so "/usr/local/lib" /usr/bin/install sqlite3 "/usr/local/bin" /usr/bin/install -m 0644 sqlite3.h sqlite3ext.h "/usr/local/include"
Verify Source-Compiled SQLite Installation on Ubuntu
/usr/local/bin/sqlite3 --version
which sqlite3
Expected output:
3.51.2 2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075 (64-bit) /usr/local/bin/sqlite3
Basic SQLite 3 Usage on Ubuntu
Use these quick checks to confirm your SQLite shell works before integrating SQLite with applications.
Create and Open a Database with SQLite on Ubuntu
sqlite3 ~/test.db
Expected shell output:
SQLite version 3.x.x Enter ".help" for usage hints. sqlite>
Create a Table and Insert Data in SQLite on Ubuntu
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO users (name) VALUES ('Test User');
SELECT * FROM users;
Expected query output:
1|Test User
Exit the SQLite shell with .quit. The database file remains at ~/test.db.
Update SQLite 3 Source Install on Ubuntu
Source installs do not update through APT. Use this script to detect the latest release, compare against your current install, and rebuild only when needed.
#!/bin/bash
set -e
BUILD_DIR="$HOME/sqlite-build"
if [ "$(id -u)" -eq 0 ]; then
echo "Run this script as a regular user. Use sudo only when make install prompts."
exit 1
fi
for cmd in curl grep sed awk tar make gcc; do
if ! command -v "$cmd" >/dev/null; then
echo "Missing required command: $cmd"
echo "Install dependencies with: sudo apt install build-essential curl"
exit 1
fi
done
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
LATEST_VERSION=$(curl -fsSL https://api.github.com/repos/sqlite/sqlite/tags?per_page=20 | grep -oE '"name": "version-[0-9]+\.[0-9]+\.[0-9]+"' | head -n 1 | sed -E 's/.*version-([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
if [ -z "$LATEST_VERSION" ]; then
echo "Could not detect the latest SQLite version from GitHub."
exit 1
fi
if command -v sqlite3 >/dev/null; then
CURRENT_VERSION=$(sqlite3 --version | awk '{print $1}')
else
CURRENT_VERSION="none"
fi
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_VERSION"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "Already up to date."
exit 0
fi
VERSION_NUM=$(echo "$LATEST_VERSION" | awk -F. '{printf "%d%02d%02d00", $1, $2, $3}')
YEAR=$(date +%Y)
echo "Preparing SQLite $LATEST_VERSION ($VERSION_NUM)..."
rm -rf "$BUILD_DIR"/sqlite-autoconf-*
curl -fLO --progress-bar "https://www.sqlite.org/${YEAR}/sqlite-autoconf-${VERSION_NUM}.tar.gz" || \
curl -fLO --progress-bar "https://www.sqlite.org/$((YEAR-1))/sqlite-autoconf-${VERSION_NUM}.tar.gz"
tar -xzf "sqlite-autoconf-${VERSION_NUM}.tar.gz"
cd "sqlite-autoconf-${VERSION_NUM}"
./configure --prefix=/usr/local
make -j"$(nproc)"
sudo make install
echo "Update complete:"
/usr/local/bin/sqlite3 --version
Run the SQLite Source Update Script on Ubuntu
nano ~/update-sqlite.sh
Paste the script, save in nano with Ctrl+O, press Enter, then exit with Ctrl+X.
chmod +x ~/update-sqlite.sh
~/update-sqlite.sh
Example output when already current:
Current version: 3.51.2 Latest version: 3.51.2 Already up to date.
Avoid automating this script with cron. Source compilation can fail because of dependency changes, upstream build changes, or network issues, so run it manually and review output each time.
Remove SQLite 3 from Ubuntu
Use the removal steps that match your installation method.
Remove APT-Installed SQLite 3 on Ubuntu
sudo apt remove sqlite3
sudo apt autoremove
Verify APT removal status:
apt-cache policy sqlite3 | sed -n '1,6p'
sqlite3:
Installed: (none)
Candidate: 3.46.1-9
Version table:
3.46.1-9 500
Remove Source-Compiled SQLite 3 on Ubuntu
If you installed SQLite with --prefix=/usr/local, remove those files and refresh the linker cache.
sudo rm -f /usr/local/bin/sqlite3
sudo rm -f /usr/local/lib/libsqlite3.so /usr/local/lib/libsqlite3.so.0 /usr/local/lib/libsqlite3.so.* /usr/local/lib/libsqlite3.a
sudo rm -f /usr/local/lib/pkgconfig/sqlite3.pc
sudo rm -f /usr/local/include/sqlite3.h /usr/local/include/sqlite3ext.h
sudo rm -f /usr/local/share/man/man1/sqlite3.1
sudo ldconfig
The next command permanently deletes your local SQLite source directory. Confirm the path before running it.
rm -rf ~/sqlite-build
Verify whether any SQLite binary remains in your PATH:
sqlite3 --version || echo "sqlite3 is not installed"
3.46.1 2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69aalt1 (64-bit) # or sqlite3 is not installed
Troubleshoot SQLite 3 on Ubuntu
These checks cover the most common installation and runtime issues seen on Ubuntu systems.
Fix “Unable to locate package sqlite3” on Ubuntu
This usually means your package index is stale or the repository metadata did not refresh correctly.
sudo apt update
apt-cache policy sqlite3
Expected output includes a candidate version:
sqlite3:
Installed: (none)
Candidate: 3.46.1-9
Version table:
3.46.1-9 500
Fix “sqlite3: command not found” on Ubuntu
dpkg -l | grep -E '^ii\s+sqlite3\b|^ii\s+libsqlite3-0\b'
If SQLite is installed, you should see package rows like:
ii libsqlite3-0:amd64 3.46.1-9 amd64 SQLite 3 shared library ii sqlite3 3.46.1-9 amd64 Command line interface for SQLite 3
If no rows appear, install SQLite with sudo apt install sqlite3. If rows appear but the command still fails, check whether your PATH includes /usr/bin or /usr/local/bin.
Resolve SQLite Library Version Conflicts on Ubuntu
sudo ldconfig
ldconfig -p | grep sqlite3
Typical output when both APT and source library paths exist:
libsqlite3.so.0 (libc6,x86-64) => /usr/local/lib/libsqlite3.so.0 libsqlite3.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libsqlite3.so.0
If both paths are listed, applications may load different library files depending on loader order and binary link paths.
Fix SQLite Database Permission Errors on Ubuntu
ls -la database.db
Example permission output:
-rw-r--r-- 1 username username 8192 Feb 16 05:40 database.db
Grant your user write access when needed, and set service ownership for web workloads. If you want a refresher on permission bits, review our chmod command guide.
chmod 664 database.db
sudo chown www-data:www-data database.db
Verify the new permissions and ownership:
ls -la database.db
-rw-rw-r-- 1 www-data www-data 8192 Feb 16 05:40 database.db
SQLite 3 Resources for Ubuntu Users
Use these references for deeper SQLite documentation and related Ubuntu workflows.
- SQLite Download Page: Official source archives and release artifacts.
- SQLite Quick Start: Core shell workflow from the upstream project.
- When to Use SQLite: Official guidance for choosing SQLite versus client-server databases.
- SQLite Documentation: API, SQL, and extension documentation.
- Python Virtual Environments on Ubuntu: Isolate Python app dependencies that rely on SQLite files.
- PHP on Ubuntu: Pair PHP with SQLite-backed local applications.
Frequently Asked Questions About SQLite on Ubuntu
No. SQLite is available in Ubuntu repositories, but the sqlite3 package is not preinstalled on most desktop, server, or container images.
Run sudo apt install sqlite3. This installs the sqlite3 command-line package from Ubuntu repositories with its required runtime library.
Yes. The sqlite3 package provides the interactive SQLite command-line shell, so you can create and query databases directly from terminal sessions.
Use APT for stability and automatic updates. Use source compilation only when you need features from a newer SQLite branch than your Ubuntu release provides.
Run sqlite3 –version to see the active binary version, then run apt-cache policy sqlite3 if you want to compare it with your repository package candidate.
Conclusion
SQLite 3 is running on Ubuntu with a setup you can maintain: APT for distribution-managed stability or source compilation in /usr/local for faster access to upstream releases. You also have tested update, removal, and troubleshooting paths that cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS.
Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed:
<code>command</code>command<strong>bold</strong><em>italic</em><a href="URL">link</a><blockquote>quote</blockquote>