When installing PostgreSQL 8.4 via Ubuntu's repositories, the configuration files follow Debian's unique directory structure:
/etc/postgresql/8.4/main/postgresql.conf
/etc/postgresql/8.4/main/pg_hba.conf
To programmatically locate these files, you can query PostgreSQL directly:
psql -U postgres -c "SHOW config_file;"
psql -U postgres -c "SHOW hba_file;"
Or use find command:
sudo find / -name postgresql.conf 2>/dev/null
sudo find / -name pg_hba.conf 2>/dev/null
In non-Debian systems or custom installations, check these locations:
- /var/lib/postgresql/data/
- /usr/local/pgsql/data/
- $PGDATA/ (if PGDATA environment variable is set)
Typical permissions for these sensitive files:
-rw-r----- 1 postgres postgres 20000 Mar 15 12:34 postgresql.conf
-rw------- 1 postgres postgres 4512 Mar 15 12:34 pg_hba.conf
For deployment scripts, consider this Bash function:
check_pg_configs() {
local pg_version=${1:-8.4}
local conf_dir="/etc/postgresql/${pg_version}/main"
if [[ ! -f "${conf_dir}/postgresql.conf" ]]; then
echo "ERROR: postgresql.conf not found in ${conf_dir}" >&2
return 1
fi
if [[ ! -f "${conf_dir}/pg_hba.conf" ]]; then
echo "ERROR: pg_hba.conf not found in ${conf_dir}" >&2
return 1
fi
echo "Configuration files verified in ${conf_dir}"
return 0
}
After modifying these files, reload the configuration:
# For Ubuntu's init system:
sudo /etc/init.d/postgresql-8.4 reload
# Alternative methods:
sudo service postgresql-8.4 reload
sudo -u postgres pg_ctlcluster 8.4 main reload
For PostgreSQL 8.4 installed via Ubuntu's repositories, the configuration files are typically found in:
/etc/postgresql/8.4/main/postgresql.conf /etc/postgresql/8.4/main/pg_hba.conf
If you're unsure about the exact location, try these PostgreSQL commands:
-- Connect to PostgreSQL and run: SHOW config_file; SHOW hba_file;
Or use Linux find command:
sudo find / -name "postgresql.conf" 2>/dev/null sudo find / -name "pg_hba.conf" 2>/dev/null
Ubuntu's PostgreSQL package maintains version-specific configuration directories. The pattern is:
/etc/postgresql/{version}/main/
Where {version} corresponds to your PostgreSQL version (8.4 in this case).
After modifying these files, remember to reload PostgreSQL:
sudo /etc/init.d/postgresql-8.4 reload # Or alternatively: sudo service postgresql reload
Best practice suggests creating backups before editing:
sudo cp /etc/postgresql/8.4/main/postgresql.conf /etc/postgresql/8.4/main/postgresql.conf.bak sudo cp /etc/postgresql/8.4/main/pg_hba.conf /etc/postgresql/8.4/main/pg_hba.conf.bak
If you're running multiple PostgreSQL clusters, each will have its own configuration directory under:
/etc/postgresql/8.4/{cluster-name}/
Use pg_lsclusters
to list all available clusters.
For this older version, some configuration parameters may differ from newer releases. Always check the version-specific documentation.