Skip to content
Download all

/var/lib/pgsql/18/data
(PGDATA)

base/
one folder per database

global/
cluster-wide tables:
roles, database list

pg_wal/
WAL files, 16 MB each

pg_xact/
commit status of transactions

log/
server log files

postgresql.conf
pg_hba.conf
pg_ident.conf
postgresql.auto.conf

PG_VERSION
postmaster.pid

On suta-linux-lab-1, as student:

suta-linux-lab-1 - as student
# Switch to the postgres user (type exit to come back)
sudo su - postgres

Now as postgres on suta-linux-lab-1:

suta-linux-lab-1 - as postgres
# The PGDG login settings set PGDATA for you
echo $PGDATA

Expected output:

/var/lib/pgsql/18/data
suta-linux-lab-1 - as postgres
# List what initdb created
ls $PGDATA

Expected output:

PG_VERSION
base
current_logfiles
global
log
pg_commit_ts
...
pg_wal
pg_xact
postgresql.auto.conf
postgresql.conf
postmaster.opts
postmaster.pid
File Controls Change takes effect after
postgresql.conf How the server runs: memory, port, listen_addresses, logging Reload, or restart for some settings
pg_hba.conf Who may connect, to which database, from where, and how they prove who they are Reload
pg_ident.conf Maps operating-system user names to database role names Reload
postgresql.auto.conf Settings written by ALTER SYSTEM (an SQL command that changes settings, later module). Do not edit by hand Reload or restart

Every pg_hba.conf line has the same columns, in this order:

# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 scram-sha-256
  • TYPE: local means the Unix socket on the same server. host means a network (TCP/IP) connection.
  • DATABASE and USER: which database and which role the line applies to.
  • ADDRESS: the client's IP address range. Only for host lines.
  • METHOD: how the client proves who it is. peer trusts the Linux user name. scram-sha-256 needs a password.

PostgreSQL reads the lines from top to bottom and uses the first line that matches.

Still as postgres on suta-linux-lab-1:

suta-linux-lab-1 - as postgres
# Show pg_hba.conf without comments and empty lines
grep -v '^#' $PGDATA/pg_hba.conf | grep -v '^$'

Expected output:

local all all peer
host all all 127.0.0.1/32 scram-sha-256
host all all ::1/128 scram-sha-256
local replication all peer
host replication all 127.0.0.1/32 scram-sha-256
host replication all ::1/128 scram-sha-256
What Where
Server log files /var/lib/pgsql/18/data/log/ (one file per weekday, for example postgresql-Wed.log)
Service messages (start, stop, failures) journalctl -u postgresql-18
initdb log /var/lib/pgsql/18/initdb.log
Programs (psql, pg_ctl, initdb, pg_dump and more) /usr/pgsql-18/bin/
Home of the postgres user /var/lib/pgsql

Still as postgres on suta-linux-lab-1:

suta-linux-lab-1 - as postgres
# Show today's log file name
ls $PGDATA/log

Expected output (yours shows today's weekday):

postgresql-Wed.log
suta-linux-lab-1 - as postgres
# Return to the student user
exit

Was this page helpful?

Thanks. Glad it helped.

Thanks for telling us. Email the instructor what was missing, or ask in class.