PostgreSQL Field Guide

Install PostgreSQL 18 on Ubuntu

Install and verify PostgreSQL from Ubuntu packages or the official PostgreSQL Apt repository

Ubuntu includes PostgreSQL, but the major version is fixed by the Ubuntu release snapshot. If that maintained default is acceptable:

sudo apt update
sudo apt install postgresql postgresql-client

Package snapshot evidence · PkgSeek

Ubuntu default postgresql metapackage

Indexed
DistributionReleaseIndexed versionRepositoryLinked advisories
Ubuntufocal12+214official / main
Ubuntujammy14+238official / main
Ubuntunoble16+257build1official / main
Ubunturesolute18+290ubuntu1official / main
Snapshot checked: Aug 2, 2026, 3:47 PM UTC. Distribution revisions and backported fixes are part of the version identity. A zero count is not a permanent security guarantee.Open package lookup

The snapshot shows that the default major changes between Ubuntu releases. postgresql follows the distribution; it does not always install PostgreSQL 18. See Linux packages and PGDG for the complete boundary.

Install PostgreSQL 18 explicitly

For a specific major, use the Apt repository maintained by the PostgreSQL project. Its automated setup path is:

sudo apt install -y postgresql-common ca-certificates
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt update
sudo apt install postgresql-18 postgresql-client-18

Read the script output and confirm that your OS release is supported. Treat the PostgreSQL Ubuntu download page as authoritative for current commands and releases.

Package snapshot evidence · PkgSeek

PkgSeek: Ubuntu / PGDG / postgresql-18

No exact indexed coordinate

PkgSeek did not return an exact match for this coordinate. This means “not present in this snapshot”, not “the package does not exist”. Confirm with the upstream repository before acting.

Snapshot checked: Aug 2, 2026, 3:47 PM UTC. Distribution revisions and backported fixes are part of the version identity. A zero count is not a permanent security guarantee.Open package lookup

If the card does not return an exact PGDG coordinate, the empty result cannot prove that the package is unavailable. Confirm against PGDG repository metadata and the official PostgreSQL download page. The documentation keeps the gap visible instead of filling it with an assumption.

Verify service and cluster

systemctl status postgresql --no-pager
pg_lsclusters
sudo -u postgres psql -X -d postgres \
  -c "select version(), current_setting('data_directory');"

postgresql.service is the cluster-management entry point; a concrete instance commonly appears as postgresql@18-main. pg_lsclusters belongs to Debian/Ubuntu postgresql-common, not every Linux distribution.

Create a local practice role and database:

sudo -u postgres createuser --pwprompt learner
sudo -u postgres createdb --owner=learner learner
psql -X -h localhost -U learner -d learner -c "select current_user;"

Do not open it to the world

Remote access involves listen_addresses, pg_hba.conf, firewall rules, and TLS together. Save the original configuration, start with a specific network/database/role rule, and test both allowed and denied paths.

Upgrade boundary

apt upgrade can install minor fixes inside one major. Moving from 17 to 18 is a major upgrade requiring pg_upgrade, logical dump/restore, or logical replication; replacing packages does not make an old data directory compatible.

Last updated on

On this page