Skip to the workspace
Pebellslearn by building
Installation, Setup and Configuring  ›  Lesson

Installing with a Package Manager

Package Managers 12 minInstall a deliberately chosen major version from the PostgreSQL project's repository and learn where your platform puts the data and config.

postgresql dba / Installing with a Package Manager

Explore each scene at your own pace.

01 · The rule

The rule

Installing with a Package Manager

Pedal is moving its database to a new Ubuntu server. The quickest command, apt install postgresql, installs whatever major version that Ubuntu release happened to ship, which may be two versions behind. A DBA chooses the version on purpose and knows where every file lands.

The rule

Choose the major version, use the project's repository, then learn the layout.

Choose the major version. PostgreSQL releases one major version a year (16, 17, 18…) and supports each for five years. Minor releases (17.5 → 17.6) are bug and security fixes, safe to apply with a normal package upgrade. Major versions change the on-disk format and need a real upgrade, so pick one deliberately and pin it.

Use the project's repository. The PostgreSQL Global Development Group (PGDG) publishes packages for every supported version:

# Debian / Ubuntu
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
sudo apt install -y postgresql-17

# Rocky / RHEL 9 (after adding the PGDG repo package)
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql17-server
sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
sudo systemctl enable --now postgresql-17

# macOS
brew install postgresql@17
brew services start postgresql@17

Learn the layout. Each family puts things in different places:

Debian / Ubuntu RHEL family
Data directory /var/lib/postgresql/17/main /var/lib/pgsql/17/data
Config files /etc/postgresql/17/main/ inside the data directory
Service name postgresql@17-main postgresql-17
First cluster created and started for you you run initdb via the setup script

Both create an operating-system user called postgres that owns the files, and a database superuser role with the same name.

If you forget a path, the server will tell you:

SHOW data_directory;
SHOW config_file;
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.