Open In App

How to Configure PostgreSQL in Linux?

Last Updated : 15 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Quick Preview to Configure PostgreSQL on Linux:

  • Install PostgreSQL on Linux:
  1. On Linux Terminal, execute the command sudo apt-get update
  2. To install and execute the command, sudo apt install postgresql postgresql-contrib
  • Check the Status of PostgreSQL on Linux:
  1. Checking status use command service postgresql status.
  • Enter Into PostgreSQL Configuration:
  1. Enter the command sudo su postgres
  2. Execute command psql.
  • Check Database & Users of PostgreSQL on Linux:
  1. To list the database, use command \l.
  2. To list users, use the command \du.
  • Configure New User on PostgreSQL on Linux:
  1. To create a Simple User use the command CREATE USER <User-Name>;
  2. To make Superuser, use the command ALTER USER <User-Name> WITH SUPERUSER;
  • Open Manual of PostgreSQL on Linux:
  1. To open the complete manual of PostgreSQL on Linux, use the command man psql.

While working on the Database Management System concept, frequently we have to work on practical problems. And one of the major steps to work on practical problems is to work on the Database Tables. If you are using the Linux Distributions Operating System, the application PostgreSQL on Linux could be the best for you.

Configuration of PostgreSQL on Linux will help you to work on the Linux Command Line tool without having any kind of issues. Also, the Installation of PostgreSQL on Linux takes a few lines which can be another plus point to the students who want to quickly start the practical practice. However, if the PostgreSQL Configuration on Linux is not perfectly done, the application will malfunction.

This article will highlight the Installation of PostgreSQL on Linux along with a few important PostgreSQL Configurational Steps on Linux.

To know more about PostgreSQL & its proper usage, you can check the article PostgreSQL Tutorial.

How to Install PostgreSQL on Linux?

Step 1: On Linux Terminal & execute the following command to update all the packages.

sudo apt-get update

1--Update

Step 2: Now, it is time to install PostgreSQL on Linux. For that, the below-mentioned command will be used.

sudo apt install postgresql postgresql-contrib 

2--Install

So, these are the simple commands needed to Install PostgreSQL on Linux. Following this, we will show some of the configuration methods, you have to perform on the Linux PostgreSQL.

How to Check the Status of PostgreSQL on Linux?

To check the status of your installed PostgreSQL on Linux, the following small command will be used. It will show the Online Status of PostgreSQL.

service postgresql status

3--Status

How to Start PostgreSQL on Linux?

You can’t directly work on PostgreSQL on Linux just like Python or Java. You need to get into PostgreSQL. To do that, the following two commands will be used.

Step 1: The first one will Enable PostgreSQL on Linux.

sudo su postgres

Step 2: The second one will help to enter into the PostgreSQL.

psql

4--Enter-PostgreSQL

How to Check Database & Users on PostgreSQL in Linux?

Step 1: To check the Database implemented in PostgreSQL, the command ‘\l’ will be used. It will mark the Database there.

5--Database

Step 2: To check the Users available in the PostgreSQL, the command ‘\du’ will be used.

6--Users

How to Configure & Modify Users on PostgreSQL on Linux?

Step 1: To create a simple & normal user, the following command will be used. It will show Create Role Message.

CREATE USER <User-Name>;

7--Create-Users

Step 2: If you want to make the New User the Superuser, the following command will be executed. It will show an Alter Role Message.

ALTER USER <User-Name> WITH SUPERUSER;

8--Alter-User

Step 3: Now, if you want to check whether the User is created or not, use the command ‘\du’ there.

9--Check

How to Open the Manual of PostgreSQL on Linux?

There are many more features present that you might use. For that purpose, use the PostgreSQL Manual on Linux. To do so, the following command will be the best.

man psql

10--Manual

From the discussion, we can confirm that one can easily now Configure PostgreSQL App on Linux. Performing a few commands there will clear the concept of PostgreSQL on Linux. If you find any difficulties, the Manual of PostgreSQL on Linux is available.

Also Read

Frequently Asked Questions: How to Configure PostgreSQL in Linux

How to configure PostgreSQL on Linux?

To configure PostgreSQL on Linux, the following steps should be executed properly.

  1. First, install the PostgreSQL on Linux.
  2. Execute the command sudo su postgres
  3. Enter command psql.

How can I check the Status of PostgreSQL on Linux?

To check the status of the PostgreSQL on Linux, a simple command should be executed. The command is the service postgresql status. It will show the status of PostgreSQL and whether it is working or not. If it is in working condition, the Online along with the port number will be visible.

What is the command to check the Database present in PostgreSQL on Linux?

The command to check the Database present in the PostgreSQL is the \l. It will mark the entire database present in the PostgreSQL created to date. However, you have to execute it, under the PostgreSQL Configuration Command.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads