hidemyname
hidemyname

Reputation: 4287

Why I can't run "psql" command?

I downloaded psql and tried to run it but it didn't work. It shows:

ubuntu@ip-172-31-17-155:~$ psql
-bash: /usr/bin/psql: No such file or directory

But I use locate to search psql it exists:

ubuntu@ip-172-31-17-155:~$ locate psql
/etc/alternatives/psql.1.gz
/usr/bin/psql
/usr/lib/postgresql/9.3/bin/psql
/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
/usr/share/bash-completion/completions/psql
/usr/share/man/man1/psql.1.gz
/usr/share/postgresql/9.3/psqlrc.sample
/usr/share/postgresql/9.3/man/man1/psql.1.gz
/var/lib/dpkg/alternatives/psql.1.gz
/var/lib/postgresql/.psql_history

what's the reason?

Upvotes: 2

Views: 3853

Answers (1)

Robert Nubel
Robert Nubel

Reputation: 7522

This looks like it's caused by Bash's path-resolution caching. You can test that theory by running:

 type psql

If it returns psql is hashed (/usr/bin/psql), then that's indeed our problem. Run:

 hash -d psql

to clear that cache, then try psql again.

Edit: I obtained the above commands from https://unix.stackexchange.com/questions/5609/how-do-i-clear-bashs-cache-of-paths-to-executables

Upvotes: 3

Related Questions