Installing on Ubuntu / Debian
The postgresql and postgresql-contrib packages come from the distribution's official repositories. The installation automatically creates and starts a cluster named main, and registers the postgresql service with systemd.
The postgres system user and database role is created. The first connection is usually made like this: sudo -u postgres psql.
Debian specifics: config and data are separate
Unlike many distributions, Debian and Ubuntu separate the configuration from the data. The postgresql.conf and pg_hba.conf files live under /etc/postgresql/<version>/main/, while the actual data is under /var/lib/postgresql/<version>/main/. The <version> corresponds to the installed major version (for example 16).
This architecture makes it possible to host several clusters side by side, managed via pg_lsclusters, pg_ctlcluster, and pg_createcluster.
Getting a newer version
The Ubuntu repositories do not always provide the very latest major version. For that, add the PostgreSQL Global Development Group repository (PGDG, apt.postgresql.org) before installing — verify against your Ubuntu version and the desired PostgreSQL version.