Access .sql script files on other partition or hdd I'm running a Linux Mint 19.1 - Tessa OS, which for you who might not know it is based on Ubuntu 18.04 - Bionic Beaver. On this I have installed postgresql 11 which work well. There is one problem though. For organisational reasons code files are stored in project directories on a separate partition of my hdd. These directories, or actually the complete partition can not be accessed from within the psql environment, even though the user account has full access to the partition normally.

To begin with, auto-completing paths with tab doesn't work for the partition and typing the path manually gives a Permission denied message. I've tried adding a su or sudo argument before the \i but it doesn't work either. Nor does starting the session from within the partition.

E.g.

user@laptop:/$ sudo -u postgres psql
[sudo] password for user:         
psql (11.5 (Ubuntu 11.5-3.pgdg18.04+1))
Type "help" for help.

postgres=# \i /media/user/Storage/Projects/DB_project/script1.sql
/media/user/Storage/Projects/DB_project/script1.sql: Permission denied
postgres=# su \i /media/user/Storage/Projects/DB_project/script1.sql
/media/user/Storage/Projects/DB_project/script1.sql: Permission denied
postgres-# ;
ERROR:  syntax error at or near "su"
LINE 1: su 
        ^
postgres=# 


For now I have to copy the files I want to use to my /home/ directory, or any directory in that tree, and then make sure to paste any updated files back in the Projects directory tree.

Any ideas on how to solve this so I don't need to copy files back and forth all the time?
Turns out this was much easier to fix than I though. Being completely new to both SQL and postgres I foolishly assumed that psql had something to do with the problem. As it turns out the directory /media/user in which Storage is mounted did not have Read &amp; Write permissions set for other users, so even though I would have been allowed to access the file inside Storage I could not get these. 

Changing the permission in /media/user solved the problem. In the future I'll make sure that all directories in a path are accessible to me.

Thanks again for the help and advice.