On 2024-08-22 at 20:38, Arbol One wrote:

> After installing PostgreSQL on my Debian-12 machine, I typed
> 'postgres --version' and got this msg: *bash: postgres: command not
> found*

$ dlocate postgres | grep postgres$
postgresql-13: /usr/lib/postgresql/13/bin/postgres
postgresql-13: /usr/lib/postgresql/13/lib/bitcode/postgres
python3-jedi:
/usr/lib/python3/dist-packages/jedi/third_party/django-stubs/django-stubs/contrib/postgres
postgresql-14: /usr/lib/postgresql/14/bin/postgres
postgresql-14: /usr/lib/postgresql/14/lib/bitcode/postgres
fpc-source-3.2.2: /usr/share/fpcsrc/3.2.2/packages/fcl-db/src/sqldb/postgres
fpc-source-3.2.2: /usr/share/fpcsrc/3.2.2/packages/postgres
postgresql-15: /usr/lib/postgresql/15/bin/postgres
postgresql-15: /usr/lib/postgresql/15/lib/bitcode/postgres
postgresql-16: /usr/lib/postgresql/16/bin/postgres
postgresql-16: /usr/lib/postgresql/16/lib/bitcode/postgres

That command won't work for you unless you have 'dlocate' installed and
'update-dlocatedb' has run since you installed the package with the file
you're looking for.

The paths above may give you a hint of where to look, however.

> 'psql --version', however, does work and gives me this message :
> 
> *psql (PostgreSQL) 16.3 (Debian 16.3-1.pgdg120+1)*
> 
> Obviously postgres is not in the path, but I don't know where the
> 'apt-get' installed it or why it did not add it to the path.

The directories for the above binaries aren't in $PATH for me, either -
not as my normal user, nor as root.

But I also don't *need* them to be. Those binaries appear to be for the
server; the server is started automatically, in my case apparently from
/etc/init.d/postgresql, in your case most likely by a systemd service of
some type. I've been running postgresql for years, and I don't think
I've ever actually *looked* for the server binaries before (although I
*have* manually run some of the other binaries from the same directory,
back when I was initially migrating from MariaDB).

If you do need to be able to manually launch the server for some reason,
you can just add the relevant directory (found as above) to your PATH
environment variable - or, of course, run it with full path.


My guess as to why the server binaries are not installed into the PATH
location(s) is that it's about coinstallability. As you can see above, I
have multiple postgresql versions installed (although in my case I think
that's due to inertia, not to any actual need for the older versions);
the only way to do that without embedding the version number into the
name of every file involved is to have the versions installed into
different directories, and of course those multiple directories won't
all be in $PATH.

That said, the same is true of the client, and the client does add a
symlink which eventually gets resolved to the correct version. There's
no reason the same couldn't be done for the server; my guess as to the
reason why it *isn't* done is that it's a combination of "there's little
reason for the user to need to run these binaries manually" with a
desire to keep the install relatively self-contained, so that it's easy
to tell each version's binaries where to find the libraries for that
version, et cetera.

> Is there a way I can locate the installation directory?

I hope this was helpful.

-- 
   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to