How to Look up PostgreSQL version on Ubuntu Linux

The tutorial instructs on identifying PostgreSQL versions on Linux systems, including Ubuntu. It explains PostgreSQL’s release and versioning schemes, as well as mentions its annual major releases that bring new features. Checking the installed PostgreSQL version is possible via the command line, PostgreSQL utility, and PostgreSQL shell, and it’s noted as especially useful for installing…

This brief tutorial shows students and new users how to find out what versions of PostgreSQL run on Ubuntu or other Linux systems.

Recently, we showed you how to install PostgreSQL on Ubuntu. Those who read that post and installed PostgreSQL may already know how to check the server version number.

For those who don’t know how the steps below should help them.

PostgreSQL is a general-purpose and object-relational database management system, probably the most advanced open-source database system…. you can also add custom functions using different programming languages such as C/C++, Java, etc.

Knowing the correct version installed on a system may be helpful, especially when installing applications with specific PostgreSQL requirements.

To get started, you must first understand how PostgreSQL is released and what versioning schemes are used. PostgreSQL versions are identified by two branches: Major and Minor.

For example, PostgreSQL version 11.6 represents Major. Minor

Every major release moves the major version number up by 1. for example, 10, 11, 12, 13, etc.

Major releases are available about once a year and are delivered with new features and major enhancements to the existing server, and each major release is supported for about 5 years.

Now that you know how to identify the PostgreSQL version numbering format, continue below to check what versions are running on a Linux system, including Ubuntu.

Identify PostgreSQL Versions via Command Line

To check which version of PostgreSQL is installed via the command line, simply run the commands below.

/usr/lib/postgresql/12/bin/postgres --version

That should display a similar line as below:

Output:
postgres (PostgreSQL) 12.1 (Ubuntu 12.1-1.pgdg18.04+1)

If you did not install PostgreSQL via the Ubuntu default repository, its binary file will not be in the system’s command PATH. You will not simply type Postgres to invoke the command.

Run the command below to locate Postgres binary file.

sudo find /usr -wholename '*/bin/postgres'

sudo updatedb
locate bin/postgres

That should display PostgreSQL binary file location as shown below.

Output:
/usr/lib/postgresql/12/bin/postgres

Using PostgreSQL Utility

You can also use the PostgreSQL utility to display its version number.

To do that, simply run the commands below:

psql --version
Output:
postgres (PostgreSQL) 12.1 (Ubuntu 12.1-1.pgdg18.04+1)

Using PostgreSQL Shell

Finally, you can also use PostgreSQL shell to display its version number.

To do that, run the commands below to sign on to the server.

sudo -u postgres psql

Then, run the shell command below to show its version number.

SHOW server_version; 

That should display its version number

Output:
server_version          
----------------------------------
 12.1 (Ubuntu 12.1-1.pgdg18.04+1)
(1 row)

Conclusion:

This brief tutorial showed you how to check the PostgreSQL version number via the command line, its utility, and the shell command. If you find any error above, please command below:

You may also like the post below:

Richard Avatar

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *