To create a database, create a user and grant privileges to the user on command line is often a requirement only when a new project is initialized. The process is described in few simple steps. The local system has a super user named 'postgres' in the Linux, who can login to local database without password. The operating System - Linux - does have the user postgres, but the password is unknown. The solution is to login to the system as a user with super user privileges. Then use sudo and su commands to login as PostgreSQL

  1. Login as postgres - the PostgreSQL Super user
    To login as postgres, use the following command
    [email protected]:~$ sudo su - postgres​

    This will prompt for the password for current user and log you in as postgres if the password is correct
    [sudo] password for vc:​

    If successfull, you will see new prompt :
    [email protected]:~$​

  2. Create database
    To create database, you can either use wrapper command createdb using following syntax
    [email protected]:~$ createdb atemon_database​

  3. Login to new database using the command psql as
    [email protected]:~$ psql​

    Now you have loged into the new database and get the psql prompt.
    psql (10.3 (Ubuntu 10.3-1.pgdg16.04+1), server 9.6.8) 
    Type "help" for help. 

  4. Now connect to the database we created just now
    postgres=# \c atemon_database​

    After connecting to the new database, you will se something similar to:
    psql (10.3 (Ubuntu 10.3-1.pgdg16.04+1), server 9.6.8) 
    You are now connected to database "atemon_database" as user "postgres". 
    atemon_database =#

  5. Create a user with password as
    atemon_database=# create user george with password 'password';

  6. Grant privileges
    Like other databases, Postgres requires privileges to be granted to the user for the database. Possible privileges that could be granted to a user are SELECT, INSERT, UPDATE, DELETE, RULE or ALL PRIVILEGES. We can grant all privileges to George on atemon as
    atemon_database=# grant all privileges on database atemon_database to george;

Now we have created a database, created a user and granted all privileges to that user.