postgres
Launch PostgreSQL server process
TLDR
Start the server on a specific port (defaults to 5432)
Set a runtime parameter (short form)
Set a runtime parameter (long form)
Start in single-user mode for a specific database (defaults to the user name)
SYNOPSIS
postgres [option...]
PARAMETERS
-D directory
Specifies the file system location of the database configuration files and data cluster.
-d level
Sets the debugging verbosity level. Higher levels provide more detailed log output.
-c name=value
Sets a run-time configuration parameter, overriding settings in postgresql.conf.
-p port
Specifies the TCP/IP port number on which the server will listen for client connections.
-i
Enables TCP/IP connections. Deprecated in favor of the listen_addresses configuration parameter.
-N max_connections
Sets the maximum number of client connections allowed to the server.
-k directory
Specifies the directory for the Unix-domain socket, overriding the default.
-h hostname
Specifies the TCP/IP address(es) on which the server will listen. Use '*' or '0.0.0.0' for all available.
-l filename
Appends all server log output to the specified file instead of standard error.
-o "options"
Passes the specified options directly to all server processes (backends).
-F
Disables fsync calls for performance, but risks data corruption on crashes. Not recommended for production.
-S
Disables synchronous_commit for performance, but risks data loss on crashes.
--single
Starts the server in single-user mode, useful for recovery or emergency administration tasks.
--name=value
Long form of -c; sets a run-time configuration parameter.
DESCRIPTION
The postgres command is the main executable for the PostgreSQL database server. It is typically started by the pg_ctl utility or by system service managers like systemd rather than being invoked directly by a user. When run, it initializes and manages the database system, listens for client connections, and executes SQL queries.
It manages individual connection processes, shared memory, and performs critical background tasks such as writing Write-Ahead Log records and managing checkpoints. Direct invocation is usually reserved for debugging, single-user mode operations, or specific configuration tests.
CAVEATS
Direct Invocation: Running postgres directly is generally not recommended for production environments. It lacks proper process management, logging rotation, and automatic restart capabilities typically provided by pg_ctl or system service managers.
Data Directory: Always ensure the specified data directory (-D) is correct and owned by the PostgreSQL user to prevent startup failures or data corruption.
Resource Management: Improper configuration of resource parameters like max_connections or shared_buffers can severely impact performance or stability.
Security: Listening on insecure addresses or ports, or with insufficient authentication settings, can expose your database to unauthorized access.
CONFIGURATION FILES
The postgres server reads its primary configuration from postgresql.conf, located within the data directory. This file contains most adjustable parameters controlling server behavior, resource usage, and security.
ENVIRONMENT VARIABLES
Several environment variables, such as PGDATA (to specify the data directory), PGPORT (for the listening port), and PGOPTIONS (for additional server options), can influence the server's behavior upon startup.
HISTORY
PostgreSQL's roots trace back to the Ingres project at UC Berkeley in the 1970s. The postgres project, initiated by Michael Stonebraker, aimed to address limitations of Ingres and began in 1986, with its first public release in 1989. The postgres server executable has been the core of the system since its inception, evolving significantly in features, performance, and stability over decades of open-source development. The project was renamed PostgreSQL in 1996 to better reflect its SQL capabilities.
SEE ALSO
pg_ctl(1), psql(1), initdb(1), pg_dump(1), pg_restore(1)


