Whenever we talk about working with the databases in any operating system, the database management systems (DBMS) are always discussed. PostgreSQL is also a DBMS that falls in the category of relational database management systems, i.e., it deals with the management and working of relational databases. This relational DBMS offers the flexibility of creating and manipulating the databases and installing them on any famous operating system, i.e., Linux, macOS, and Windows. This is exactly why this DBMS is all the more famous across many programmers out there.

This relational DBMS is free and open-source, contributing more to its wide usage within the different industrial sectors. Moreover, the kind of transactions that this DBMS deals with is ACID, i.e., it can efficiently perform the transactions with ACID properties (atomicity, consistency, isolation, and durability). It means that if you have the data with these properties and want to create a relational database for it, you should definitely consider using the PostgreSQL server.

Since the launch of this relational DBMS back in 1996, it has undergone several upgrades, which is why its functionality is comparable with any of the latest relational database management systems. Moreover, this DBMS also provides enhancements in the traditional database management systems’ features and perfect compliance with SQL. This relational DBMS supports a wide range of native data types and some user-defined data types. In addition to that, it also handles the different versions of your databases while maintaining their concurrency in an extremely graceful manner.

The concept of inheritance also works well with the tables created within the databases of this DBMS. It means that you can let a table inherit its parent table’s properties very conveniently while using the PostgreSQL server. Other than that, this DBMS also allows you to back up your data online, preventing any data losses. Moreover, it also supports point-in-time recovery for easier access to the recovered data. By now, we have sufficiently discussed the relevant features of the PostgreSQL server. Now, it is the right time to talk about the actual focus of this article.

This article intends to teach you the installation procedure of the PostgreSQL server on a Linux distribution, i.e., Ubuntu 20.04. You can also use any other Linux flavor of your choice if you wish so. However, the method shared below will work perfectly well with a Ubuntu 20.04 system.

Method of Getting started with PostgreSQL in Ubuntu 20.04:

For getting started with PostgreSQL on a Ubuntu 20.04 system, you need to perform the following steps in the specified order:

Step # 1: Get your System Ready for PostgreSQL Installation:

Before we install anything on any Linux distribution, it is highly recommended to have an updated system. This goal can be achieved with the help of the command stated below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-1.png" data-lazy- height="25" src="data:image/svg xml,” width=”393″>

Step # 2: Run the Installation Command for PostgreSQL:

Once the above-mentioned command has finished its execution, the next step is to execute the following command in your Ubuntu 20.04 terminal:

$ sudo apt install postgresql

This command will install PostgreSQL on our Ubuntu 20.04 system, which is mandatory for us, i.e., we will not be able to start it if it is not installed on our Ubuntu 20.04 system.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-2.png" data-lazy- height="25" src="data:image/svg xml,” width=”486″>

With this command, you will be able to install PostgreSQL on your system very conveniently, and this whole process will take a few minutes to complete; however, we already had it installed on our system. Therefore, we were presented with the message shown in the image below once we executed the command mentioned above on our Ubuntu 20.04 system:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-3.png" data-lazy- height="127" src="data:image/svg xml,” width=”524″>

However, once you are installing the PostgreSQL server on your Ubuntu 20.04 system (if it is not already installed on it), then during the installation, you will be asked once to confirm your action. Once you will do that, the installation process of the PostgreSQL server will continue on your Ubuntu 20.04 system, and it will terminate upon a successful installation hence displaying a success message on the terminal.

Step # 3: Verify the Active Status of PostgreSQL:

We also need to verify that the PostgreSQL server is active on our system. For that, we can check its status with the following command:

$ sudo systemctl status postgresql

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-4.png" data-lazy- height="25" src="data:image/svg xml,” width=”526″>

The output presented in the image shown below verifies that PostgreSQL is active on our system. However, a point to be noted over here is that this server is not running now. It will only run once we start this server. This is exactly why the status turned out to be “active (exited)” instead of “active (running)”.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-5.png" data-lazy- height="174" src="data:image/svg xml,” width=”643″>

Step # 4: Start PostgreSQL by Accessing its Server:

After verifying the status of the PostgreSQL server on our Ubuntu 20.04 system, we will access this server so that it can start running with the help of the following command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-6.png" data-lazy- height="24" src="data:image/svg xml,” width=”424″>

Your PostgreSQL server will immediately start running on your Ubuntu 20.04 system as soon as this command is executed. You can confirm this by taking a look at the changed path on your system’s terminal.

Step # 5: Enter the PostgreSQL Console:

Finally, for playing around with the databases, we need to enter the PostgreSQL console, which can be done with the command shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-7.png" data-lazy- height="45" src="data:image/svg xml,” width=”432″>

You can see the PostgreSQL console in the following image:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-8.png" data-lazy- height="111" src="data:image/svg xml,” width=”438″>

After entering this console, you can instantly start working with databases by executing different queries of your choice in this console.

Additional Tip:

As an additional tip, we would like to teach you how to go back to your normal terminal in Ubuntu 20.04. For that, you first need to exit from the PostgreSQL console, after which you will have to log out from the PostgreSQL server. This can be done by following the two tips shared below:

Tip # 1: How to Exit from the PostgreSQL Console?

For exiting from the PostgreSQL server’s console, you need to type “q” in that console and press the Enter key as shown in the following image:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-9.png" data-lazy- height="110" src="data:image/svg xml,” width=”464″>

Once you will do that, you will be out of the PostgreSQL server’s console.

Tip # 2: How to Logout from the PostgreSQL Server?

Now for logging out of the PostgreSQL server, you need to run the command shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/How-to-start-PostgreSQL-in-Linux-10.png" data-lazy- height="131" src="data:image/svg xml,” width=”455″>

When you run this command, you will be successfully logged out of the PostgreSQL server.

Conclusion:

You can easily realize from this tutorial how simple it is to start PostgreSQL on a Linux system. We have used a Ubuntu 20.04 system for explaining this method. The main thing that you need to have is the PostgreSQL server installed on your system. If you have installed it on your system and its status is active, then it is just a matter of a few seconds for you to start this server on your system. Moreover, as an additional tip, we also taught you how to get out of the PostgreSQL server’s console and how to log out of this server.

About the author

<img data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/09/echo/Author-Image-150×150.jpg6133dc61a757b.jpg" height="112" src="data:image/svg xml,” width=”112″>

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.