Verify What Versions of PostgreSQL Running on Ubuntu 18.04 | 16.04

This brief tutorial shows students and new users how to find out what versions of PostgreSQL running 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 come in handy, especially when installing applications with specific PostgreSQL requirements..

To get started, you must first understand how PostgreSQL are 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.. example: 10, 11, 12, 13, etc.

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

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

Identifying 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 similar line as below:

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

If you did not install PostgreSQL via 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 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 PostgreSQL version number via the command line, its utility and shell command… If you find any error above, please command below:

You may also like the post below:

Mantis Bug Tracker (MantisBT) on Ubuntu 18.04 | 16.04 with Apache2

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.