1

I created an Ubuntu 14.04.4 server on digital ocean.

I have a directory off the root user called mapnik/data/. Inside is a file I want to import to postgres. When logged in as root

ls -l /root/mapnik/data/world_merc.shp

yields

-rw-r--r-- 1 postgres root 428328 Apr  7 18:17 /root/mapnik/data/world_merc.shp

When trying to import to postgres, I cannot access the file. If logged in as postgres

ls -l /root/mapnik/data/world_merc.shp

yields

ls: cannot access /root/mapnik/data/world_merc.shp: Permission denied

Is this an issue with the permission on this folder?

How can I configure this folders permissions so I can import from root to postgres?

2

That's because user postgres does have not have necessary permission to read (list) the contents of directory /root/ (the home directory of user root).

Normally the permission of /root/ is set as 0700 with the owner as root, so nobody else except root can check the contents and hence traverse further in the directory tree.

So even if you set the owner of /root/mapnik/data/world_merc.shp file as user postgres, postgres won't be able to access the file as the traversal will be blocked because of insufficient permission at /root/.


Instead of putting the file in /root/ (and changing permission of /root/), choose postgres's home (if there is one) or you home or any place that seems safe and user postgres has sufficient permission to do the intended operation.

4
  • Could I change the permissions of the folder so that postgres can import from /root/mapnik/data ?
    – jotamon
    Apr 8 '16 at 19:53
  • @snowgage Check my edits..you should not change the permission of /root/
    – heemayl
    Apr 8 '16 at 19:54
  • Very helpful.. Thanks.. When I log in as postgres could I just store my files right at that users root? e.g. /var/lib/postgresql/data ?
    – jotamon
    Apr 8 '16 at 20:07
  • 1
    @snowgage If /var/lib/postgresql/data is postgres user's home, then Yes, you obviously should !! Check the permissions to be sure..
    – heemayl
    Apr 8 '16 at 20:11

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.