PostgreSQL | Terminal Command Collection
Initialize the DB
initdb --encoding=UTF-8 --no-locale --username={user name} --pgdata={database directory}
Create a DB
createdb --encoding=UTF-8 --username=root --owner=root --port=5432 {database name}
Start the DB
pg_ctl start --pgdata={database directory} --log={log file}
Do not run pg_ctl as root. Because the configuration file is used, if it is owned by postgres and pg_ctl start is run with root privileges, privileges may be granted.
This is the escalation attack pointed out by iDEFENSE. Of course, the postmaster fails, but to protect inexperienced system administrators, it should fail earlier.
The selected fix is to disable root use of pg_ctl in all cases.
Stop the DB
pg_ctl stop --pgdata={database directory} -m fast
Connect to the DB
psql --host=127.0.0.1 --port=5432 --username={user name} --dbname={database name} --password
Check the table list.
\dt
Exit.
\q