I'm using Ubuntu 14.04. When logged in as root, I'm tryhing to run a command as anotehr (postgres). However, it is failing

root@remotebox:/home/rails/myproject# su - postgres 'pg_upgradecluster 9.3 main'
-su: pg_upgradecluster 9.3 main: No such file or directory

What am I doing wrong?


You're trying to pass 'pg_upgradecluster 9.3 main' to the default shell for postgres user. Depending on postgres user configuration this may mean to execute 'pg_upgradecluster 9.3 main' file in postgres PATH, and this is the reason you get a "No such file or directory error".

Try pass the argument as a command (-c):

su - postgres -c 'pg_upgradecluster 9.3 main'

as a shell:

su - postgres -s /path/to/pg_upgradecluster -- 9.3 main

or to explicit choose the shell:

su - postgres -s /bin/bash -- -c 'pg_upgradecluster 9.3 main'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.