Skip to main content

Did I Already Install Postgres?

did-i-already-install-postgres-hangover-meme

1. Check if the psql client exists​

psql --version

If installed, you’ll see something like:

psql (PostgreSQL) 15.3

If not installed:

command not found

2. Check if the postgres service exists​

systemctl status postgresql
  • If installed + running β†’ you’ll see active (running)
  • If installed but stopped β†’ inactive
  • If not installed β†’ β€œUnit postgresql.service could not be found”

3. Check installed packages (more definitive)​

dpkg -l | grep postgres

This will list anything like:

postgresql
postgresql-15
postgresql-client-15

πŸ‘‰ This is the most reliable β€œis it installed at all” check.


4. Check if the binary exists directly​

which psql
  • If installed β†’ /usr/bin/psql
  • If not β†’ no output

5. Bonus: check if a server is actually running​

pg_isready
  • If running β†’ accepting connections
  • If not β†’ no response

Quick mental model (very you-friendly)​

  • psql β†’ β€œcan I talk to postgres?”
  • systemctl β†’ β€œis postgres running as a service?”
  • dpkg β†’ β€œis postgres installed at all?”

Comments

No comments yet. Be the first!