Users can be created either by using the command createuser or one the SQL statements CREATE ROLE or CREATE USER.
The createuser command, which is a wrapper to the SQL Command CREATE ROLE, has the added advantage of providing for the interactive creation users by answering a series of questions. To run createuser interactively you use the –interactive command line switch.
The following code snippet will create a user in interactive mode by prompting for details to the user.
createuser --interactive --pwprompt
To create a user non interactively you can use the command createuser as follows.
create user user_name with encrypted password 'mypassword';
More info on createuser here:
https://www.postgresql.org/docs/current/app-createuser.html
Users can also be created by SQL:
CREATE USER 'username' PASSWORD 'password';
CREATE ROLE 'username' PASSWORD 'password';
More on CREATE USER and CREATE ROLE here:
https://www.postgresql.org/docs/current/sql-createuser.html
https://www.postgresql.org/docs/9.3/sql-createrole.html