Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vECH6-0077RI-U2 for pgsql-sql@arkaria.postgresql.org; Wed, 29 Oct 2025 19:56:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vECH4-003WP0-K5 for pgsql-sql@arkaria.postgresql.org; Wed, 29 Oct 2025 19:56:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vECH4-003WOs-BW for pgsql-sql@lists.postgresql.org; Wed, 29 Oct 2025 19:56:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vECH1-004RLv-2H for pgsql-sql@lists.postgresql.org; Wed, 29 Oct 2025 19:56:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 59TJtrlk2892302; Wed, 29 Oct 2025 15:55:53 -0400 From: Tom Lane To: Krzysztof cc: pgsql-sql@lists.postgresql.org Subject: Re: Linux file permission for COPY TO SQL command In-reply-to: References: <8ABD45BB-37B7-4394-AB59-10BC1C25797F@gmail.com> <7d2f7e34-c724-4227-a1c2-8d5882a6a3d4@gmail.com> Comments: In-reply-to Krzysztof message dated "Wed, 29 Oct 2025 19:44:01 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2892300.1761767753.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 29 Oct 2025 15:55:53 -0400 Message-ID: <2892301.1761767753@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Krzysztof writes: > Actually server and client are installed on the same machine. > The file (real file) permissions are as follows: > -rwxrwxrwx+ 1 kaj kaj 2 Oct 27 22:36 fd/fdo.txt > The directory permissions are as follows: > drwxrwxrwx+ =C2=A04 kaj kaj =C2=A0=C2=A0=C2=A0=C2=A04096 Oct 27 22:36 fd > The SQL command which tries to write to the file is this: > copy (select key from xcg where add=3Dfalse) to '/home/kaj/fd/fdo.txt'; The /home and /home/kaj directories would also need to be world-searchable for the server to be able to write there. (Do not make them world-writable...) Did you notice the HINT that goes with that error message? HINT: COPY TO instructs the PostgreSQL server process to write a file. Yo= u may want a client-side facility such as psql's \copy. regards, tom lane