install postgres on linux

  1. Update the package list:

sudo apt update

  1. Install PostgreSQL:

sudo apt-get install postgresql

  1. Verify the installation:

psql --version

  1. Start and enable PostgreSQL service:

sudo systemctl start postgresql sudo systemctl enable postgresql

  1. Configure PostgreSQL:

Open the PostgreSQL configuration file:

sudo nano /etc/postgresql//main/postgresql.conf

Update the following lines:

  • Uncomment the line "listen_addresses = 'localhost'" to allow connections from the local machine.
  • Uncomment the line "max_connections = 100" to set the maximum number of connections.
  • Save and exit the file.

  • Create a new PostgreSQL user:

sudo -u postgres createuser --interactive

Follow the prompts to create a new user with desired privileges.

  1. Create a new PostgreSQL database:

sudo -u postgres createdb

Replace "" with the desired name for your database.

  1. Connect to the PostgreSQL database:

sudo -u postgres psql

You will now be in the PostgreSQL command-line interface.

  1. Perform further configuration or setup as needed.

Remember to adjust the commands and file paths based on your specific Linux distribution and PostgreSQL version.