How to print current working directory in psql console?

Viewed 26191

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?

3 Answers

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.

I am shocked that no one answered the question directly in over 2 years. Everyone assumes that because you are using postgres that you must be running Linux. Well, postgres is now becoming a very popular DBMS on Windows 10.

In Windows 10, in a psql command prompt type "! dir" to print the current working directory.

To change directories in the Windows 10 psql client, "\cd /users/yourlogin".

The psql client is a unix shell running on Windows, so it is a mix of unix and dos syntax commands.

Just you use this command it will display your current working directory

pwd

Related