Why doesn't sudo know where psql is?
The problem
The CKAN installation documentation shows you how to list the installed
PostgreSQL databases.
The command looks like this:
sudo -u postgres psql -l
When I try that in my shell, I get an error:
$ sudo -u postgres psql -l
sudo: psql: command not found
The workaround
Daniel2d2art on the CentOS forum worked around the problem by fully
qualifying the path to psql.
My psql lives in the directory /usr/pgsql-9.2/bin, so my workaround now
looks like this:
sudo -u postgres /usr/pgsql-9.2/bin/psql -l
When I try that in my shell, it works:
$ sudo -u postgres /usr/pgsql-9.2/bin/psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access
privileges
--------------+----------+----------+-------------+-------------+-----------------------
postgis_test | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres +
| | | | |
postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
=c/postgres +
| | | | |
postgres=CTc/postgres
(4 rows)
How do I fix it properly?
I shouldn't have to fully qualify the path, right?
The postgres user already has psql in its path:
$ sudo -u postgres echo $PATH
/usr/pgsql-9.2/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
How do I fix this properly?
No comments:
Post a Comment