It appears that the Postgresql installation is split into three folder locations on Debian:

Configuration: /etc/postgresql

Binaries: /usr/lib/postgresql

Data: /var/lib/postgresql

I understand the benefits of splitting up the configuration files and the data, however, the binaries location is confusing to me -- why wouldn't it simply be in /usr/bin?

More to the point, why would some binaries go into /usr/bin and others into /usr/lib?

2 Answers 2


It is Debian distribution policy that configuration files, binaries, and data are stored at these three different locations. There are various reasons for this, including:

  • consistency between packages
  • easier to tell which directories to back up, to audit, to tune, etc.
  • could mount /usr read-only

The reason the binaries are split over two directories has to do with how Debian manages to allow installing multiple major versions of PostgreSQL in parallel. The details of this are explained /usr/share/doc/postgresql-common/architecture.html. In summary:

  • All programs are stored in /usr/lib/postgresql/X.Y/bin.
  • For server-side programs, you can call those directly with a full path, or use Debian wrappers like pg_ctlcluster to access them.
  • For client-side programs, symlinks are put into /usr/bin that point to pg_wrapper, which automatically figures out the right version to call.

This splitting is pretty typical for most services. I'm on Fedora but most distributions do the same in terms of organizing files based on their type, into designated areas.

Taking a look at the Postgres SQL server:

  1. The configuration files go into /etc/
  2. Executables go into /usr/bin
  3. Libraries go into /usr/lib64/pgsql/
  4. Locale information goes into /usr/share/locale/
  5. Man pages and docs goes into /usr/share/
  6. Data goes into /var/lib/

The rational for having a libraries directory usr/lib/postgresql in your case, which is equivalent to /usr/lib64/pgsql/ for my install, is that applications can make use of libraries of functions that are provided by Postgres. These functions are contained in these libraries.

So as an application developer, you could link against the libraries here to incorporate function calls into Postgres, into your application. These libraries will often times include API documentation, and the developers of Postgres make sure to keep their API specified and working correctly through these libraries, so that applications that make use of them, can be guaranteed that they'll work correctly with this particular version of Postgres.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .