Postgresql – How to figure out how Postgres was installed on the Linux system

linuxpostgresqlstartup

I'm using Postges 9.6 on Ubuntu Linux 16. I'm trying to figure out how the Postgres server was installed so I can figure out a command to start and stop it. It evidently isn't installed as a Linux service

[rails@server ~]$ sudo service postgresql status
Redirecting to /bin/systemctl status postgresql.service
Unit postgresql.service could not be found.

"which psql" reveals

[rails@server ~]$ which psql
/usr/bin/psql

I'm sort of at a loss for the next steps in figure out the command to start and stop it.

Best Answer

If you are simply looking to start and stop it, and a service or systemctl module doesn't exist on your machine, you can use pg_ctl to start and stop the Postgres server. You will also need to have the path to the data directory handy (typically, the folder that contains postgresql.conf and pg_hba.conf), and pass that in along with the -D flag:

pg_ctl -D /path/to/data_dir start|stop

If no data directory exists, you will either need further assistance to help you get an existing database cluster up and running, or you can use initdb to create a new database cluster