Solution 1:

If it's just a matter of calling on psql directly you need to make sure the path "/usr/local/pgsql/bin" is included in $PATH when you are logging in. Oftentimes this has to do with setting the PATH variable appropriately in in /etc/profile (or ~/.profile) or if you are using bash, then this would be /etc/bashrc or ~/.bashrc.

e.g.

export PATH="$PATH:/usr/local/psql/bin"

Additionally.. the psql command expects the args as follow; psql <dbname> <username> (you can use --flags to specify the same).

If you supply "psql test"- then it will assume the username of the current user (as seen by whoami command).

Hope this helps.

Solution 2:

Why not use the Linux Alias?

alias psql=/usr/local/pgsql/bin/psql

To make a permanent alias, just put this line in

~/.bashrc or ~/.bash_profile