Create Postgres DB from command line in Ubuntu 14.04

On ubuntu shell,

sudo su postgres
createdb mydb -O dbownername

If it says “dbownername” role does not exist, you can create it with

createuser dbownername


If above commands does not work, you may be missing following

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


for more information  createdb manual  createuser manual