The PostgreSQL client (psql) is a powerful command-line tool used to interact with PostgreSQL databases. However, the default versions included with Linux distributions are often behind the latest stable release.
In this guide, we’ll walk through installing the latest PostgreSQL client on:
- Ubuntu 22.04 (Jammy)
- Ubuntu 24.04 (Noble)
- AlmaLinux 9
- AlmaLinux 10
Why Install the Latest psql?
- Feature compatibility – New PostgreSQL servers (15, 16, 17…) may have features that older clients don’t support.
- Security updates – Latest packages include bug and security fixes.
- Improved performance and tools – Enhancements in
psqlcommands and options.
Installing Latest psql on Ubuntu
Both Ubuntu 22.04 and 24.04 include PostgreSQL in their default repositories, but those versions lag behind. To stay current, use the official PostgreSQL APT repository (PGDG).
Step 1: Add the PostgreSQL APT Repository
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
sudo apt update sudo apt install wget ca-certificates -y wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo tee /etc/apt/trusted.gpg.d/postgresql.asc > /dev/null # For Ubuntu 22.04 (Jammy) echo "deb http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" | \ sudo tee /etc/apt/sources.list.d/pgdg.list # For Ubuntu 24.04 (Noble) echo "deb http://apt.postgresql.org/pub/repos/apt noble-pgdg main" | \ sudo tee /etc/apt/sources.list.d/pgdg.list |
Step 2: Update Package Lists
|
1 2 |
sudo apt update |
Step 3: Install the Latest Client
|
1 2 |
sudo apt install postgresql-client |
This installs the most recent stable version (currently PostgreSQL 17 as of September 2025).
If you want a specific version (e.g., PostgreSQL 16):
|
1 2 |
sudo apt install postgresql-client-16 |
Step 4: Verify Installation
|
1 2 |
psql --version |
Installing Latest psql on AlmaLinux
AlmaLinux, like RHEL and CentOS, ships with an older version by default. To get the latest, you’ll use the PostgreSQL Yum/DNF repository maintained by PGDG.
Step 1: Enable the PostgreSQL Yum Repository
|
1 2 |
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm |
This command automatically detects whether you’re on AlmaLinux 9 or AlmaLinux 10.
Step 2: Disable the Built-in PostgreSQL Module
|
1 2 |
sudo dnf -qy module disable postgresql |
Step 3: Install the Latest Client
|
1 2 |
sudo dnf install -y postgresql17 |
(Substitute postgresql16, postgresql15, etc. if you want a specific version.)
Step 4: Verify Installation
|
1 2 |
psql --version |
Keeping psql Updated
- On Ubuntu, once you’ve added the PGDG APT repo,
apt upgradewill automatically keeppsqlupdated. - On AlmaLinux,
dnf upgradewill pull in updates from the PGDG repo.
Conclusion
By using the official PostgreSQL repositories, you’ll always have the most recent version of psql on your system, whether you’re running Ubuntu or AlmaLinux. This ensures compatibility with modern PostgreSQL servers, access to the latest features, and ongoing security updates.




