Install PostgreSQL in Ubuntu 20.04

This guide shows you how to install and configure PostgreSQL on Ubuntu 20.04. Let's get started.
Update the system
Updating your system is essential. First, fetch the latest package lists from the repositories so that the package manager knows about every new patch and security release.
sudo apt-get updateInstall PostgreSQL
Run the install command. This installs PostgreSQL along with the postgresql-contrib package, which adds extra tools and features.
sudo apt install postgresql postgresql-contribOpen PostgreSQL prompt
Let's test it. Switch to the default postgres user and start the interactive command-line interface, psql, to verify that the installation succeeded.
sudo -i -u postgres psql
Exit the prompt
Exit the prompt.
\qCreate a new user
You can add database roles. Run the interactive utility, specify the role name, and decide if it needs superuser status.
sudo -u postgres createuser --interactiveCreate a new database
Create a new database instance for your application or user.
sudo -u postgres createdb sammyAdd the Unix user
Create a corresponding system user on your Ubuntu host.
sudo adduser sammyChange the user password
Log back into PostgreSQL and change the password for your database user.
sudo -u postgres psql
ALTER USER samy PASSWORD 'myPassword';
\q