It is necessary to create one command that will execute several commands in the terminal (bash), including the initialization of the user with a password. List and order of command execution:
su postgres(a password is requested here);- password entry ; - here, as I understand it, you will not get off with a simple semicolon.
export PATH=$PATH:/usr/local/pgsql/bin;- this is entered from the user posgresexport PGDATA=/usr/local/pgsql/data;pg_ctl start -l logfile;psql -c 'select now()';psql
Debian System Example:
Pangea @ Caesar: ~ $ startpsql;
-longs the list of all the above commands.

startpsql. write#!/bin/bashfirst line andsudo -u postgres startpsql2second line. Create next filestartpsql2write in it with the first line#!/bin/bashafter which all the lines to be executed under postgres. On both files, set permissions to execute thechmod a+x файл. Configure sudo to allow startps to the desired user without a password - Mike