S.Hossein Asadollahi
S.Hossein Asadollahi

Reputation: 1650

Postgres find configuration files in linux

I've spent lots of time to find Postgres configuration files like pg_hba.conf or postgresql.conf in different distributions of linux and also postgres versions itself! and I was very confused...

Upvotes: 5

Views: 25723

Answers (2)

S.Hossein Asadollahi
S.Hossein Asadollahi

Reputation: 1650

Finally, I found the global solution for it.

First, you should follow these steps:

  1. Type su - postgres or, if that does not work, sudo -i -u postgres and hit Enter.

  2. Type psql and hit Enter.

  3. To find out the location of the postgres configuration file postgresql.conf, type:

    SHOW config_file;
    

    The output should be like this:

    postgres=# SHOW config_file;
                   config_file               
    -----------------------------------------
     /etc/postgresql/9.6/main/postgresql.conf
    (1 row)
    
  4. And to find out the location of the postgres pg_hba.conf file, type:

    SHOW hba_file;
    

    There, the output should be like this:

    postgres=# SHOW hba_file;
                  hba_file               
    -------------------------------------
     /etc/postgresql/9.6/main/pg_hba.conf
    (1 row)
    

Upvotes: 21

Vao Tsun
Vao Tsun

Reputation: 51406

If you instance is not started and you can't

select current_setting('hba_file')

or

select setting from pg_settings where name = 'hba_file'

or

psql -c 'show hba_file'

you can just find them:

find / -name pg_hba.conf

Upvotes: 3

Related Questions