
The Mouse Brothers
June 14, 2025
Securing SSH on Kali: Public-Key Auth, Disable Passwords & Fail2Ban Lockouts
June 14, 2025How to install Postgress on Kali Linux
PostgreSQL (Postgres) is a powerful, open-source, object-relational database management system (ORDBMS) known for its robust features, reliability, and scalability. It’s often referred to as the world’s most advanced open-source database, suitable for both enterprise-level applications and smaller projects. In this guide, we’ll walk through installing Postgres on Kali Linux — whether you’re setting up a local development environment, a lab for penetration testing tools that require a database backend, or simply adding database capabilities to your Kali box. The install process is straightforward, and within a few minutes you’ll have a fully functional Postgres instance ready to go.
1. Update your system
Refresh your package lists and install all available updates before moving on:
sudo apt update && sudo apt upgrade -y
Why?
sudo apt update
syncs your local package index with the repo and
sudo apt upgrade -y
applies every pending upgrade automatically.
2. Install PostgreSQL
sudo apt install postgresql postgresql-contrib -y
3. Start and enable the service
You’re basically switching to the postgres user shell.
To go back to your original user:
or just press Ctrl + D
That logs you out of the postgres shell and drops you back to your original user/session.
6. Access psql prompt
psql is PostgreSQL’s built-in command-line tool. It lets you connect directly to your database, run SQL queries, create tables, manage users, and check your data. If you’re used to MySQL or SQLite, it’s basically the same idea — your main interface for interacting with Postgres.
psql
Once you’re inside the psql prompt, you can try a few basic commands:
\l
— list all databases\du
— list roles/users\conninfo
— show current connection info\q
— quit psql\?
— \h shows SQL syntax help (e.g. \h SELECT)
For example, to create a new database:
CREATE DATABASE mytestdb;
And to connect to it:
\c mytestdb
That’s enough to get you started with psql. You can always type \?
inside psql to see all available commands.
7. PostgreSQL Python Support (psycopg2 Install)
If you’re planning to interact with Postgres using Python (which is super common for apps, automation scripts, data analysis, etc), you’ll need to install a couple of extra packages that provide the database bindings:
sudo apt install libpq-dev python3-psycopg2
Here’s a quick rundown of what these do:
- libpq-dev: This installs the PostgreSQL client library headers. It’s basically the C library that psycopg2 (and other tools) need behind the scenes to actually talk to PostgreSQL. Without this, psycopg2 won’t compile or run properly.
- python3-psycopg2: This is the main Python adapter. It lets your Python code connect to Postgres, run SQL queries, insert data, fetch results and do pretty much anything you can do manually in psql, but from your Python scripts or apps.
After installing these your Python code can easily connect to Postgres like this:
import psycopg2
That’s all you need to get Python talking to Postgres on Kali.
Ready for a reliable, high-performance VPS at an unbeatable price? We host our own Kali labs on Hostinger: 4 vCPU, NVMe storage, 16 GB RAM, and 16 TB bandwidth—backed by 24/7 support and a 30-day money-back guarantee. You’ll save up to 20% when you lock in a 24-month plan. Grab a Hostinger VPS using this referral link and support our content.
👉 Claim your Hostinger VPS (from only US$ 9.99/mo)