Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Where are the files postgresql.conf and pg_hba.conf on a Linux server running PostgreSQL 8.4 installed from Ubuntu repos?

share|improve this question

migrated from Jun 20 '10 at 13:42

This question came from our site for professional and enthusiast programmers.

The problem is b/w the chair and the keyboard. It depends on how you installed it. Did you use source tar-gz file or did you use apt utility. If you download tar-gzipped file and installed it. The pg_hba.conf file does not exist yet unless you initialize your data directory. The INSTALL/Readme file has that info. You will find pg_hba.conf file in whatever you selected as your data directory. Secondly, if you used apt utility then you should find it in /etc/postgresql/8.4/main you can also do a 'find' on the filename but doing that on the entire disk is cpu-consuming. – Nikolas Sakic Jun 20 '10 at 17:56
Installing from source to the default install location, you run the following: /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data before starting postgres and hba file will be created in that directory. – Nikolas Sakic Jun 20 '10 at 17:59
up vote 10 down vote accepted

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

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.)

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.
share|improve this answer

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)

share|improve this answer


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.