PostgreSQL is one of the most popular database management systems. It’s a free and open-source software which is renowned for stability, performance, scalability, and security. Many applications and programming languages (Python, JavaScript, Ruby, C/C++, and more) support the PostgreSQL integration. Learn more about PostgreSQL.
In this guide, we will take a quick look at removing the PostgreSQL on Ubuntu 22.04.
To perform the steps in this guide, you need the following components:
Step 1: Finding the Installed PostgreSQL Packages
The default method of installing PostgreSQL on Ubuntu is through the APT package manager. The package source can be either the official Ubuntu package repo or the official PostgreSQL APT repo.
First, we check the list of installed packages that contains the term, postgres:
Step 2: Uninstalling PostgreSQL Altogether
Notice that all the packages that are related to PostgreSQL start with the term, postgresql. Using this pattern, we can specify what packages to uninstall to the APT package manager.
Using the following command, we can easily remove all the PostgreSQL packages:
Here,
Note that it removes all the installed versions of PostgreSQL. If you want to remove a specific version of PostgreSQL, we have to follow a more specific method.
Step 3: Uninstalling a Specific Version
Certain cluster setups may utilize multiple versions of PostgreSQL for compatibility reasons. In such an environment, removing all the PostgreSQL packages may not be suitable. In that case, we can remove a specific version of PostgreSQL.
By checking the list of installed PostgreSQL packages, we can easily determine the versions that are currently installed:
Here,
For reference, the release notes page lists all the available versions of PostgreSQL.
Now that we have a target, we can uninstall it using the following command:
We explored the various ways of uninstalling PostgreSQL on Ubuntu. We demonstrated on how to uninstall a specific version as well as uninstall PostgreSQL altogether from the system.
Interested in learning more about PostgreSQL? If you intend to use multiple versions of PostgreSQL on the same machine, you have to assign different ports for each database server. It’s also possible to integrate the PostgreSQL in Java apps using JDBC.
The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…
Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…
Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…
Focal Fossa will reach the End of Standard Support in May 2025, also known as…
Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…
Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…