Skip to content

Instantly share code, notes, and snippets.

@Iftakharpy
Last active January 10, 2025 20:22
Show Gist options
  • Save Iftakharpy/c48217566a7e779f90acebed94ae63a6 to your computer and use it in GitHub Desktop.
Save Iftakharpy/c48217566a7e779f90acebed94ae63a6 to your computer and use it in GitHub Desktop.
Note of necessary commands to set up postgresql on linux

Installation

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql postgresql-contrib

postgresql.conf file

ls /etc/postgresql/<version>/main/ here postgresql.conf is the configuration file for postgresql

Service

service postgresql

Check status

service postgresql status

Login as postgres user(first time)

sudo su postgres

get posgtres shell

psql

List current databases present in postgres db

\l

List users

\du

Change password for default postgres user

ALTER USER postgres WITH PASSWORD "new_password";

Create new user

CREATE USER user_name WITH PASSWORD "password";

check users

\du

Give A user superuser previliges

ALTER USER user_name WITH SUPERUSER;

Remove user

DROP USER user_name;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment