SQLite is the practical choice when a script, test app, or small web project needs SQL without a separate database server. You can install SQLite 3 on Ubuntu from the default APT repositories for the lowest-maintenance path, while source compilation is available when you specifically need a newer upstream branch.
Ubuntu includes SQLite packages in its repositories, but the sqlite3 command-line shell is not normally preinstalled on desktop, server, or minimal images. These steps cover Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS, with APT as the recommended method for most users.
Install SQLite 3 on Ubuntu
Quick SQLite 3 Install Command on Ubuntu
On a standard Ubuntu system, refresh package metadata and install the repository package:
sudo apt update
sudo apt install sqlite3
These commands use
sudofor system-level package installation. If your account does not have sudo access yet, follow our guide on how to add a new user to sudoers on Ubuntu.
If an older script or tutorial uses apt-get, the package name is the same:
sudo apt-get install sqlite3
Use the full method notes below when you need version checks, source compilation, cleanup commands, or troubleshooting.
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 Branch | Updates | Best Fit |
|---|---|---|---|---|
| APT (Recommended) | Ubuntu default repositories | Ubuntu release branch | Automatic through standard APT upgrades | Most users needing stable packages |
| Source Compilation | Official SQLite source archive | Current upstream release | Manual rebuilds | Developers needing newer SQLite features quickly |
Default SQLite 3 Versions by Ubuntu Release
Ubuntu packages different SQLite branches by LTS release. Use this table for branch-level planning, then run apt-cache policy sqlite3 when you need the exact package revision currently available from your configured mirrors.
| Ubuntu Release | sqlite3 Branch | Typical Package Source | Notes |
|---|---|---|---|
| Ubuntu 26.04 LTS | SQLite 3.46.x | resolute/main | Current LTS repository package |
| Ubuntu 24.04 LTS | SQLite 3.45.x | noble-updates or noble-security | Established LTS package branch |
| Ubuntu 22.04 LTS | SQLite 3.37.x | jammy-updates or jammy-security | Oldest LTS release covered here |
Do not shorten the command to sudo apt install sqlite. Ubuntu 22.04 still exposes sqlite as a legacy SQLite 2 package from Universe, while Ubuntu 24.04 and 26.04 use sqlite3 for the supported SQLite 3 command-line shell.
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. If you are compiling another program against Ubuntu’s packaged SQLite library, install the development headers separately:
sudo apt install libsqlite3-dev
Verify SQLite 3 APT Installation on Ubuntu
sqlite3 --version
command -v sqlite3
Example output on Ubuntu 26.04:
3.46.1 2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69aalt1 (64-bit) /usr/bin/sqlite3
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 libreadline-dev zlib1g-dev
This installs GCC, make, curl, readline headers, and zlib headers. The readline and zlib development packages let the source-built SQLite shell keep command-line editing and compression support instead of falling back to a thinner build.
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, read the current autoconf archive path from the official SQLite download page, then download that archive from sqlite.org.
mkdir -p ~/sqlite-build
cd ~/sqlite-build
DOWNLOAD_PAGE=$(curl -fsSL https://www.sqlite.org/download.html)
ARCHIVE_PATH=$(printf '%s\n' "$DOWNLOAD_PAGE" | grep -oE '[0-9]{4}/sqlite-autoconf-[0-9]+\.tar\.gz' | head -n 1)
if [ -z "$ARCHIVE_PATH" ]; then
echo "Could not detect SQLite autoconf archive."
exit 1
fi
ARCHIVE=${ARCHIVE_PATH##*/}
VERSION_NUM=$(printf '%s\n' "$ARCHIVE" | grep -oE '[0-9]+')
SQLITE_VERSION=$(printf '%s\n' "$VERSION_NUM" | awk '{major=substr($1,1,length($1)-6); minor=substr($1,length($1)-5,2)+0; patch=substr($1,length($1)-3,2)+0; printf "%s.%d.%d", major, minor, patch}')
echo "Latest SQLite release: $SQLITE_VERSION"
echo "Archive path: $ARCHIVE_PATH"
curl -fLO --progress-bar "https://www.sqlite.org/${ARCHIVE_PATH}"
The command prints the release and archive path before the download progress bar reaches 100%.
If the download page format changes and the archive detection fails, open the SQLite download page, copy the current
sqlite-autoconf-*.tar.gzpath, and setARCHIVE_PATHmanually before rerunning the download command.
Extract and Configure SQLite Source on Ubuntu
tar -xzf "$ARCHIVE"
cd "${ARCHIVE%.tar.gz}"
./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.
Relevant configure output includes:
Checking for zlib.h...ok Line-editing support for the sqlite3 shell: readline 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
command -v sqlite3
The first line should show the upstream release you just built. The second line should confirm the /usr/local binary path:
/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
The SQLite prompt opens after the startup hint:
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 read the current SQLite autoconf archive from sqlite.org, compare it with your /usr/local build, 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 awk tar make gcc nproc; do
if ! command -v "$cmd" >/dev/null; then
echo "Missing required command: $cmd"
echo "Install dependencies with: sudo apt install build-essential curl libreadline-dev zlib1g-dev"
exit 1
fi
done
if [ ! -f /usr/include/readline/readline.h ] || [ ! -f /usr/include/zlib.h ]; then
echo "Missing readline or zlib development headers."
echo "Install dependencies with: sudo apt install build-essential curl libreadline-dev zlib1g-dev"
exit 1
fi
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
DOWNLOAD_PAGE=$(curl -fsSL https://www.sqlite.org/download.html)
ARCHIVE_PATH=$(printf '%s\n' "$DOWNLOAD_PAGE" | grep -oE '[0-9]{4}/sqlite-autoconf-[0-9]+\.tar\.gz' | head -n 1)
if [ -z "$ARCHIVE_PATH" ]; then
echo "Could not detect SQLite autoconf archive."
exit 1
fi
ARCHIVE=${ARCHIVE_PATH##*/}
VERSION_NUM=$(printf '%s\n' "$ARCHIVE" | grep -oE '[0-9]+')
LATEST_VERSION=$(printf '%s\n' "$VERSION_NUM" | awk '{major=substr($1,1,length($1)-6); minor=substr($1,length($1)-5,2)+0; patch=substr($1,length($1)-3,2)+0; printf "%s.%d.%d", major, minor, patch}')
if [ -x /usr/local/bin/sqlite3 ]; then
CURRENT_VERSION=$(/usr/local/bin/sqlite3 --version | awk '{print $1}')
else
CURRENT_VERSION="none"
fi
echo "Current source version: $CURRENT_VERSION"
echo "Latest source version: $LATEST_VERSION"
echo "Archive path: $ARCHIVE_PATH"
if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
echo "Already up to date."
exit 0
fi
echo "Preparing SQLite $LATEST_VERSION..."
rm -rf "$BUILD_DIR"/sqlite-autoconf-* "$BUILD_DIR"/sqlite-autoconf-*.tar.gz
curl -fLO --progress-bar "https://www.sqlite.org/${ARCHIVE_PATH}"
tar -xzf "$ARCHIVE"
cd "${ARCHIVE%.tar.gz}"
./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
When the source build is already current, the script ends with:
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 -y sqlite3
Verify the package is no longer installed with package-manager state first:
dpkg -l sqlite3 2>/dev/null | grep '^ii' || echo "sqlite3 is not installed"
sqlite3 is not installed
Preview orphaned dependencies before removing anything else. Reused systems can already have unrelated kernels or libraries marked autoremovable, so review the package list before continuing. For a broader cleanup refresher, see our guide on removing packages on Ubuntu from the command line.
sudo apt autoremove --dry-run
If the preview only lists packages you expect to remove, run the real cleanup interactively:
sudo apt autoremove
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 /usr/local/lib/libsqlite3.la
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
Refresh the shell command cache, then verify which SQLite binary remains in your PATH. If the APT package is still installed, this can return /usr/bin/sqlite3; otherwise it should report that no SQLite binary is available.
hash -r
command -v sqlite3 || echo "sqlite3 is not in PATH"
sqlite3 is not in PATH
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
Relevant lines include an installed state and a non-empty candidate. Ubuntu 26.04 currently reports:
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[[:space:]]+sqlite3[[:space:]]|^ii[[:space:]]+libsqlite3-0[[:space:]]'
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 upstream references for deeper SQLite documentation.
- 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.
Conclusion
SQLite 3 is available on Ubuntu through the low-maintenance sqlite3 APT package, with source compilation in /usr/local reserved for systems that need the newest upstream branch. If SQLite becomes part of a local application stack, pair it with Python virtual environments on Ubuntu or PHP on Ubuntu for the next layer of setup.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>