How to print current working directory in psql console?

Don P picture Don P · Jul 13, 2017 · Viewed 16.1k times · Source

I am trying to restore a schema on a remote server using the psql console in pgAdmin and an sql dump file. I receive the following error:

user=> \i file.sql
file.sql: No such file or directory

I can't seem to print the directory listings due to lacking superuser privileges.

Is there a way to identify or print the current working directory in psql console? What is the default directory?

Answer

vipulsinghthakur picture vipulsinghthakur · May 10, 2018

Typing in the command \! pwd will print the current working directory in psql. To change working directory use command \cd <path>; replace <path> with desired path. Eg. Running command \cd /run/mount will change the current working directory to /run/mount. Try changing the your working directory to that containing the file which you want to run and then use \i meta command as you did earlier. It will definitely work.