How to check PostgreSQL version in Linux?


PostgreSQL, often referred to as Postgres, is a powerful and open-source relational database management system (RDBMS). It is known for its robustness, extensibility, and support for advanced SQL features. PostgreSQL is widely used for data storage and retrieval in a variety of applications, from small projects to large-scale enterprise systems.

To check the PostgreSQL version installed on a Linux system, you can use the psql command-line utility, which is the command-line client for PostgreSQL. Here’s how to do it:

  1. Open Terminal: Launch the terminal on your Linux system.
  2. Login to PostgreSQL: You can log in to the PostgreSQL database by running the following command. Replace <username> with your PostgreSQL username.

You may be prompted to enter your PostgreSQL password.

  1. Check the Version: Once you are logged in, you can check the PostgreSQL version by running the following SQL query:

This will display the PostgreSQL version, along with additional information about the installation.

  1. Exit PostgreSQL: After checking the version, you can exit the PostgreSQL prompt by typing:

This will return you to the regular Linux terminal.

Alternatively, if you don’t want to log in to PostgreSQL, you can check the version without logging in by running the following command in your terminal:

This will display the PostgreSQL version without requiring you to log in to the database.

Remember to replace <username> with your actual PostgreSQL username if you choose to log in.

You can find more information about PostgreSQL on the official PostgreSQL website (https://www.postgresql.org) and in the PostgreSQL documentation (https://www.postgresql.org/docs/).