In this article, I will show you how to install and set up PostgreSQL on a Linux server.
Make sure you have:
A Linux server
Internet access to install packages
Step 1: Log into your Ubuntu server
you can use the command,
ssh username@server_ip_
Then you'll be prompted to enter your password.
If the password entered is correct then you are in the server.
Step 2: Install PostgreSQL
Search https://www.postgresql.org/download/ to see the download versions of available. In this article, I will show you how to install and set up PostgreSQL on a Linux server. Make sure you have: A Linux server Internet access to install packages Step 1: Log into your Ubuntu server you can use the command, Step 2: Install PostgreSQL Search https://www.postgresql.org/download/ to see the download versions of available. Copy and paste the lines of code as below into your ubuntu server, and you'll have downloaded posgresql. Step 3: Connect to PostgreSQL PostgreSQL creates a system user named postgres. You can switch to this user to open the PostgreSQL prompt: Then type, psql. postgres=# To exit the prompt, type: Then return to your regular user: Step 4: Create a New Database and User If you want to create a new PostgreSQL user and database: Switch to the postgres user: Create a new user: It will prompt you for a username and whether the new user should be a superuser. Create a new database: Now you can select the database you want to use and add tables and values to it, to select use Check posgres status: To stop posgresql: To start posgresql: To restart posgresql:
Select the one for linux and ubuntu.
You'll get the image below.
ssh username@server_ip_
Then you'll be prompted to enter your password.
If the password entered is correct then you are in the server.
Select the one for linux and ubuntu.
You'll get the image below.

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
. /etc/os-release
sudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
sudo apt update
sudo apt -y install postgresql-16
We use,
sudo -i -u postgres
You should now be at the PostgreSQL prompt:
\qexit
sudo -i -u postgres
createuser --user_name
createdb database_name
\c database_name
Then from there you can add your tables and values.
sudo systemctl status posgresql
sudo systemctl stop posgresql
sudo systemctl start posgresql
sudo systemctl restart posgresql