How To Install PostgreSQL 17 on Kali Linux 2025.x

In this guide, we are going to look at how to install PostgreSQL 17 on Kali Linux 2025.x. Let’s first get to know what PostgreSQL is before we start on installation.

What is PostgreSQL?

PostgreSQL is an enterprise-class and open-source relational database, advanced to support both relational queries (SQL) and non-relational (JSON) queries. PostgreSQL supports a higher number of data types that are not found in MySQL and it is also possible for one to create own data types, index types and operators. It is community-driven, having more than 30 years of community support thus making it highly resilient and stable with notable levels of integrity. This helps developers in building fault-tolerant environments as well as protect information integrity. PostgreSQL has formed the primary database for web, mobile, analytics and geospatial applications. Due to its performance optimization features and advanced data types, PostgreSQL competes with the highly valued commercial databases such as OracleDB.

Features of PostgreSQL

Some of the important features of PostgreSQL include:

  • Support for different data types as well as user-defined types
  • Table inheritance
  • Ensures data integrity – foreign key referential intergrity
  • High levels of security
  • Nested transactions
  • Reliability and disaster recovery – supports asynchronous replication and point-in-time recovery
  • Extensibility
  • Sophisticated locking mechanism

Installing PostgreSQL 17 on Kali Linux 2025.x

The below steps will take us through how to install PostgreSQL on Kali Linux and to test how to create a database. Kali Linux is a Debian-based distribution and therefore we are going to be using ‘apt’ package manager.

Step 1: Update system packages

The first recommended thing to do always is to ensure that our systems run the latest packages before the installations. Once updated, reboot the system to enable the new changes to take effect.

sudo apt update && sudo apt upgrade -y
sudo reboot

Step 2: Install PostgreSQL 17 on Kali Linux

Postgresql 17 is already included in Kali Linux 2025.x. Check the availability of PostgreSQL in Kali Linux by running the below command:

$ sudo apt show postgresql                           
Package: postgresql
Version: 17+264
Priority: optional
Section: database
Source: postgresql-common (264)
Maintainer: Debian PostgreSQL Maintainers <[email protected]>
Installed-Size: 18.4 kB
Depends: postgresql-17
Suggests: postgresql-doc
Tag: devel::lang:sql, interface::daemon, network::server, network::service,
 role::metapackage, role::program, suite::postgresql, works-with::db
Download-Size: 12.2 kB
APT-Manual-Installed: no
APT-Sources: http://http.kali.org/kali kali-rolling/main amd64 Packages
Description: object-relational SQL database (supported version)
 This metapackage always depends on the currently supported PostgreSQL
 database server version.
 .
 PostgreSQL is a fully featured object-relational database management
 system.  It supports a large part of the SQL standard and is designed
 to be extensible by users in many aspects.  Some of the features are:
 ACID transactions, foreign keys, views, sequences, subqueries,
 triggers, user-defined types and functions, outer joins, multiversion
 concurrency control.  Graphical user interfaces and bindings for many
 programming languages are available as well.

If you need to install run the command as below:

sudo apt install postgresql -y

You can go ahead to start postgresql in Kali Linux using any of the following commands:

sudo systemctl enable --now postgresql
sudo systemctl start postgresql

Confirm if running

$ systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
     Active: active (exited) since Wed 2025-03-26 17:14:58 EAT; 9s ago
 Invocation: b836513fd4c148d886c836f61022a920
    Process: 1504 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 1504 (code=exited, status=0/SUCCESS)
   Mem peak: 1.6M
        CPU: 6ms

Mar 26 17:14:58 kali.cloudspinx.com systemd[1]: Starting postgresql.service - PostgreSQL RDBMS...
Mar 26 17:14:58 kali.cloudspinx.com systemd[1]: Finished postgresql.service - PostgreSQL RDBMS.

Step 3: Test PostgreSQL installation on Kali Linux

Check if you can connect to PostgreSQL to create a test database. When PostgreSQL is installed, a default user called ‘postgres’ is created. Change to this user:

 sudo su - postgres

To secure the default postgres user with a strong password, use the following command:

$ psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
postgres=# \q

To run Postgresql commands, let’s enter PostgreSQL command prompt with the below command:

$ psql
psql (17.4 (Debian 17.4-1))
Type "help" for help.

postgres=# 

To list any available databases, use the command below:

$ \l
                                                     List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | 
 template0 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
(3 rows)

To create a database, run the below command:

CREATE DATABASE testdb;

Confirm database was created

# \l
                                                     List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | 
 template0 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
 testdb    | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | 
(4 rows)

To create a user and grant them privileges to the database we created earlier, run the following commands:

postgres=# CREATE USER testuser WITH ENCRYPTED PASSWORD 'MyPassword';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE testdb to testuser;
GRANT

To connect to the database you just created, use the command below:

# \c testdb
You are now connected to database "testdb" as user "postgres".
testdb=# 

Step 4: Configure PostgreSQL Remote Access

PostgreSQL has configurations file that you can make changes to when needed. I am going to show you how to edit listening addresses and enable remote access. Open the configuration file as below:

sudo vim /etc/postgresql/17/main/postgresql.conf 

Under ‘Connection and Authentication’, uncomment line 59; #listen_addresses=’localhost’ and edit the same line as below to either allow to listen on any interface or on specific interfaces:

# To listen on all interfaces
listen_addresses = '*'

# To enable only specified private IP address
listen_addresses = '192.168.1.181'

To enable remote connections edit the below file:

sudo vim /etc/postgresql/17/main/pg_hba.conf

Make the below changes:

# To accept connections from anywhere
host all all 0.0.0.0/0 md5

# To accept only from trusted subnet
host all all 10.10.10.0/24 md5

Once you make the above changes, you need to restart postgresql as below

sudo systemctl restart postgresql

To disable remote access for Postgresql database, open the above configuration files and add a ‘#‘ at the beginning of the lines to disable. For example, to disable remote access from any, edit the line to look like below and remember to restart postgresql when done.

#host all all 0.0.0.0/0 md5

From the client machine:

psql -h <server_ip> -U <username> -d <database_name>
#Example
psql -h 192.168.1.100 -U testuser -d testdb

This has been a guide on how to install Postgresql database on Kali Linux. As explained earlier, Postgresql is one of the most used databases due to its stability and high performance. It is pretty easy to get Postgresql database up and running on any Linux system and its commands are quite simple as well.

PostgreSQL Learning materials:

I hope the guide has been helpful in getting you started with Postgresql database on Kali Linux. Check below more interesting guides:

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

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

Related Post

In this tech-driven world, systems and devices intertwine seamlessly to improve our quality of life. Computerized devices have become integral […]

In today’s workplace, collaboration is no longer a buzzword but a crucial piece of a business setup. With this strategy, […]

Any network professional need a boost in their skills when it comes to network routing, switching, general troubleshooting, IP addressing, […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.