This blog post teaches you how to install PostgreSQL on AlmaLinux 10. PostgreSQL, or Postgres, is a free and open-source object relational database management system for storing data. PostgreSQL is a powerful RDBMS with various features, such as transactions with atomicity, consistency, isolation, durability, automatic updates, etc. It is compatible with multiple operating systems like Windows, macOS, FreeBSD, and Linux. In the following paragraphs, we will show you how to install the PostgreSQL database management system, manage the service, and use some basic commands.
Installing PostgreSQL on AlmaLinux is straightforward and may take up to 10 minutes. Let’s get started!
Table of Contents
Prerequisites
- A server running AlmaLinux 10 or any Linux OS
- User privileges: root or non-root user with sudo privileges
Update the system
Before we start the installation process of the PostgreSQL database system, it is recommended that the system packages be updated to their latest available versions. To do that, execute the following command:
sudo dnf update -y && sudo dnf upgrade -y
Install PostgreSQL database server
The PostgreSQL repository is by default added to the latest AlmaLinux 10 OS. To install the latest PostgreSQL 16, execute the following command:
sudo dnf install postgresql-server postgresql-contrib postgresql -y
Once installed, you can check the PostgreSQL version and verify if PostgreSQL was installed successfully. To do that, execute the command below:
postgres --version
You should get the following output:
[root@host ~]# postgres --version postgres (PostgreSQL) 16.4
Manage the PostgreSQL service
After successful installation, to start and enable PostgreSQL for automatic start on system boot, execute the command below:
sudo systemctl start postgresql && sudo systemctl enable postgresql
To check the status of the service, you can use the following command:
sudo systemctl status postgresql
If everything is OK, you will receive output similar to this:
root@host ~]# sudo systemctl status postgresql ● postgresql.service - PostgreSQL database server Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled) Active: active (running) since Sun 2025-04-05 10:47:09 CDT; 41min ago Invocation: deb4221eaa0b447f94a583925e15fe4c Main PID: 1907 (postgres) Tasks: 7 (limit: 23175) Memory: 19.5M (peak: 22.4M) CPU: 647ms CGroup: /system.slice/postgresql.service ├─1907 /usr/bin/postgres -D /var/lib/pgsql/data ├─1909 "postgres: logger " ├─1910 "postgres: checkpointer " ├─1911 "postgres: background writer " ├─1913 "postgres: walwriter " ├─1914 "postgres: autovacuum launcher " └─1915 "postgres: logical replication launcher " Apr 05 10:47:09 host.test.vps systemd[1]: Starting postgresql.service - PostgreSQL database server... Apr 05 10:47:09 host.test.vps postgres[1907]: 2025-04-05 10:47:09.309 CDT [1907] LOG: redirecting log output to logging collector process Apr 05 10:47:09 host.test.vps postgres[1907]: 2025-04-05 10:47:09.309 CDT [1907] HINT: Future log output will appear in directory "log". Apr 05 10:47:09 host.test.vps systemd[1]: Started postgresql.service - PostgreSQL database server.
Stopping the PostgreSQL service can be done with:
sudo systemctl stop postgresql
Restarting the service with:
sudo systemctl restart postgresql
There is another way to check if PostgreSQL is running on your server, and that is by checking port 5432, which is the default PostgreSQL port:
netstat -tunlp | grep 5432
Since, with the previous status command we already know that PostgreSQL is running successfully, you should receive output similar to this:
[root@host ~]# netstat -tunlp | grep 5432 tcp6 0 0 ::1:5432 :::* LISTEN 1907/postgres
The PostgreSQL console
The PostgreSQL command line is essential for managing the databases, creating users, setting passwords, granting permissions, etc. First, we will show you how to log in to the PostgreSQL command line. Execute the following command:
sudo -u postgres psql
After this command, you will be logged into the PostgreSQL console:
[root@host ~]# sudo -u postgres psql psql (16.4) Type "help" for help. postgres=#
To create a new user database and grant permissions to that user, execute the following commands one by one:
CREATE DATABASE rhtestdb; CREATE USER rhtestuser WITH ENCRYPTED PASSWORD 'YourStrongPasswordHere'; GRANT ALL PRIVILEGES ON DATABASE rhtestdb TO rhtestuser;
While executing the command above, you will receive confirming messages if the database and user are created, as shown in the output below:
postgres=# CREATE DATABASE rhtestdb; CREATE DATABASE postgres=# CREATE USER rhtestuser WITH ENCRYPTED PASSWORD 'YourStrongPasswordHere'; CREATE ROLE postgres=# GRANT ALL PRIVILEGES ON DATABASE rhtestdb TO rhtestuser; GRANT postgres=#
Now, when the database and user are created, we can list the database with the command below:
\l
You will get output similar to this:
postgres=# \l List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges -----------+----------+----------+-----------------+---------+---------+------------+-----------+------------------------- postgres | postgres | UTF8 | libc | C.UTF-8 | C.UTF-8 | | | rhtestdb | postgres | UTF8 | libc | C.UTF-8 | C.UTF-8 | | | =Tc/postgres + | | | | | | | | postgres=CTc/postgres + | | | | | | | | rhtestuser=CTc/postgres template0 | postgres | UTF8 | libc | C.UTF-8 | C.UTF-8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | libc | C.UTF-8 | C.UTF-8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres (4 rows) postgres=#
Through the PostgreSQL console, you can execute different SQL queries. To quit from the console, you need to use the following command:
\q
PostgreSQL Configuration File
The PostgreSQL configuration file is a vital file where you can configure some values, such as max connections, remote access, restricted access, how much RAM to use for the PostgreSQL service, on which port to listen to the service, etc. The location of the PostgreSQL configuration file is at:
/var/lib/pgsql/data/postgresql.conf
The following lines of code are examples from postgresql.conf file:
# - Connection Settings - #listen_addresses = 'localhost' # what IP address(es) to listen on; #port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) # - Memory - shared_buffers = 128MB # min 128kB # - Where to Log logging_collector = on log_filename = 'postgresql-%a.log' log_rotation_age = 1d
That’s it. You successfully installed the PostgreSQL database system on AlmaLinux 10 and learned some basic commands.
Of course, you don’t have to do this if you have difficulties and are unfamiliar with Linux and database servers. You can always contact our technical support. You only need to sign up for one of our NVMe AlmaLinux VPS server plans and submit a support ticket. We are available 24/7 and will take care of your request immediately.
If you liked this post on how to install PostgreSQL on AlmaLinux 10, please share it with your friends or leave a comment below.