How to do it…

We just need to launch the following command:

pg_controldata <data-directory> | grep "system identifier"
Database system identifier: 5558338346489861223

Note that the preceding syntax will not work on Debian or Ubuntu systems, for the same reasons explained for initdb in the Locating the database server files recipe. However, in this case, there is no postgresql-common alternative, so if you must run pg_controldata, you need to specify the full path to the executable, as in this example:

/usr/lib/postgresql/10/bin/pg_controldata $PGDATA

Don't use -D in front of the data directory name. This is the only PostgreSQL server application where you don't need to do that.