Location of postgresql.conf and pg_hba.conf on an Ubuntu server

Solution 1:

Open a command prompt.

> psql -U postgres
=# show hba_file;
=# show config_file

When they change the names of the config settings, or you want to see something else.

=# show all;

Solution 2:

Looking for "pg_hba.conf ubuntu" on Google gives you

https://help.ubuntu.com/community/PostgreSQL

which shows the location of the files.

The documentation states the following:

Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in the database cluster's data directory. (HBA stands for host-based authentication.) A default pg_hba.conf file is installed when the data directory is initialized by initdb. It is possible to place the authentication configuration file elsewhere, however; see the hba_file configuration parameter.

Note it says stored in the database cluster's data directory and that it's possible to place it elsewhere, via a configuration parameter. Official documentation cannot point you to a specific folder because the actual location depends on both how the OS maker and the machine's administrator have set PostgreSQL up. Remember PostgreSQL supports a lot of different operating systems (and Linux distributions.)

As Neutrino shows, if you can access your server via psql, you can tell it to show you the file location.

Also, two tips:

  1. locate will help you find files you know the name of but not the location
  2. Debian based distributions place under /usr/share/doc documentation on how they set up different packages by default, I'm sure you'll find under /usr/share/doc/postgresql-8.4 (or maybe just postgresql) info about the configuration files. Very useful to read in case they have modified some standard behavior.

Solution 3:

Possibly

/etc/postgresql/9.*/main

Solution 4:

http://www.postgresql.org/docs/current/static/runtime-config-file-locations.html


Solution 5:

As Vinko said, the location is distribution-dependent. To add to his answer:

Your package management sofware will tell you where are the files installed by each package, (for example: dpkg -L postgresql).

You can also look inside the service startup script ( typically /etc/init.d/postgresql)