PostgreSQL Logo

PostgreSQL Documentation

Linux Administration & Environment Setup

Setup PostgreSQL Environment Variables on Linux

Configure PostgreSQL environment variables for enterprise Linux administration, automation and PostgreSQL operational management.

Overview

PostgreSQL environment variables simplify database administration by allowing Linux shells and scripts to automatically access PostgreSQL binaries, data directories and tools.

This guide demonstrates how to configure PostgreSQL environment variables permanently on Linux systems.

Configure Environment Variables

Step 1 — Open Bash Profile

Open the bash profile file for the PostgreSQL user.

vi ~/.bash_profile

Step 2 — Add PostgreSQL Variables

Add PostgreSQL binary and data paths.

export PATH=/usr/pgsql-17/bin:$PATH
export PGDATA=/var/lib/pgsql/17/data

Step 3 — Save File

Save and exit the editor.

:wq

Step 4 — Reload Profile

Reload the profile configuration.

source ~/.bash_profile

Verify Configuration

Verify PostgreSQL PATH

which psql

Check PostgreSQL Version

psql --version

Verify PGDATA

echo $PGDATA

Need PostgreSQL Enterprise Support?

PostgreSQL administration, replication architecture, high availability, performance tuning and enterprise DBA consulting.

Contact Now ikram5@zohomail.in