When you install postgresql on 14.04, it sticks the main server program postgres at:
/usr/lib/postgresql/9.3/bin/postgres
the data directory where all the database clusters will be stored at:
/var/lib/postgresql/9.3/main
and the configuration file at:
/etc/postgresql/9.3/main/postgresql.conf
Now I can understand why postgresql.conf and other configuration files are stored in /etc/postgresql/9.3/main. After all, /etc is where configuration files are stored in a linux system.
However, why place the database storage area in /var/lib? I can understand /var, since that is the place for nonstatic data and databases are nonstatic. But why /var/lib in particular?
Further, I believe that /bin is for programs required for boot. /usr/bin is for programs included in the distribution. and /usr/local/bin should be for programs not included in the distribution but available for system-wide use. And thus since postgresql is intended for system-wide use, it should be available in /usr/local/bin. Yet, they place it in /usr/lib, which I have no idea why.
Why do I ask this question? Because without order and structure, it is difficult to remember the location of programs you use everyday.
Best Answer
In the Filesystem Hierarchy Standard, `/var/lib/ is stated as (in italic the most important part):
In short: /var/lib/ is for data that is used locally.
So it makes perfect sense to put a database's data into /var/lib/{mysql|postgress}/ directory but... the FHS is a standard created mostly for use by distributions. As a user you are free to put your data wherever you want and it is mostly a matter of opinion.
You are misunderstanding the word "local". /usr/local/bin/ is not for system software but for your own software (basically anything with "local" in must never be touched by the system. As explained by FHS:
/usr/local/
An executable installed from system software should never go to anything local.
Now for /usr/lib/.
postgressql is probably a daemon started at boot? If so it makes sense to put it here. You are not suppose to use the command yourself but start a service. The files in /usr/lib/ tend to have their own user and group and/or a daemon that restricts access to /var/lib (only mysqld can access /var/lib/mysql/ for instance; this will be the same for postgressql)