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-clientPackage snapshot evidence · PkgSeek
Ubuntu default postgresql metapackage
| Distribution | Release | Indexed version | Repository | Linked advisories |
|---|---|---|---|---|
| Ubuntu | focal | 12+214 | official / main | — |
| Ubuntu | jammy | 14+238 | official / main | — |
| Ubuntu | noble | 16+257build1 | official / main | — |
| Ubuntu | resolute | 18+290ubuntu1 | official / main | — |
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-18Read 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
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.
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
PostgreSQL Linux packages, versions, and PGDG
Verify PostgreSQL 18, PostgreSQL 19, client, and extension packages by Linux distribution, with repository, version, and backport boundaries
Install PostgreSQL 18 on macOS
Compare Homebrew, Postgres.app, and the graphical installer, then verify the local server