Find PostgreSQL data directory and configuration file location

In this tutorial, we are going to find data directory and configuration files paths in PostgreSQL Server.

If environment variables configured, then we can get the data directory path by running below command on Linux Shell i.e.

echo $PGDATA. If it is not set then we have to execute SQL statements. 1. Find the data directory path in PostgreSQL Server.

select setting from pg_settings where name = 'data_directory';

or

show data_directory;

2. Find the hba file location PostgreSQL Server.

select setting from pg_settings where name like '%hba%';

or

show hba_file;

3. Find the ident file location PostgreSQL server.

select setting from pg_settings where name like '%ident%';

or

show ident_file;