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 1vECW0-007Doj-AA for pgsql-sql@arkaria.postgresql.org; Wed, 29 Oct 2025 20:11:27 +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 1vECVz-003YKr-3O for pgsql-sql@arkaria.postgresql.org; Wed, 29 Oct 2025 20:11:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vECVy-003YKj-QQ for pgsql-sql@lists.postgresql.org; Wed, 29 Oct 2025 20:11:25 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vECVv-004wTJ-1y for pgsql-sql@lists.postgresql.org; Wed, 29 Oct 2025 20:11:25 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-37775ed97daso14554371fa.0 for ; Wed, 29 Oct 2025 13:11:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761768682; x=1762373482; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=IgoGi04hkuXzjOGnibwmtTwpVpVLBhlNNq741sMSqRQ=; b=ZlVqoXIDL3wHB6J6bEoO9+7fzsZGrw4M3y1tppx8oydOJbpqpA3fXZ6kPUUVpRmroq YvhRz1ffOYzXliSKiAbqH2BtloysV1wmbAEahfxQaRQUUpSa0lYff+A1817JYD+eTjtX PqMEWY44VjHfKv0YL7zfuXvRq0IHiJ7NLuUKTSVjMunprJsJSbGACKZYIDA+lp0zdxo7 BMmucSwb1hdI9tZnJSA4MVJ3shJvvlDxOGhR39EdYeHdOKCzW4P6rgi4i+26tqB2zkSV Nh+KsPytN++70j3HuRa7H15IQ/MKhqZR3eH3lfbj/vSOXY9+K0/wGxfaGubaQqPrL095 6doQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761768682; x=1762373482; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IgoGi04hkuXzjOGnibwmtTwpVpVLBhlNNq741sMSqRQ=; b=rE4z8G75/f0WMYM01D5VSmoJPajBaLbOd4P8ETt33oS1wuELb4/ZVGmGBc9p7aKM0g hxjwFiCwvtZSI/tZYHu0FINdu2G2hfTWmeaz0VB/D90vBAlraqSij2RGrCaHEXwDt23M slXPT7MvkqJwfkGAalOgXfVUgCkrQtXhwLgse11H94joZ/cxi9uzkLqV9rEHRPGre0bH s7Ivnb9z3cqYGP6JVgCe1uYLIJh057ArOeOGtCTiBp6qUgXjeGu+gwp/zyuKWZMjH6Sl p9coHySpbApkJA4bc1WccICWBC20U+YhKWNROH3emTR2FDC5woTlHzY5iLF6rqpA2e5o QQAg== X-Gm-Message-State: AOJu0Yx2IZS9hOdznL9ImwncGIgN7TdVaCGSxdy34fjVnCd/hj0yOAU1 wil6s2/oRI1YETfcYFKEtFb1zhzOWpbGKUVM4Rap+PUxkoXF44vyFdqmEy180g== X-Gm-Gg: ASbGncswh83QYDVvvzWbFlXrrm/e0y5NmkZABCrQpen2ppVfwq9miBn4CE3Q0HFvpJQ TkC2J91IU7y55mbHZqzQdUrcI2zHP5V12QOhDS9bhf7OChcY4nqNMpjySaWG0gLD8988UYhblCu EZHgykBpGLvaQ6l/34LJfCqAUzmG5KZHZQI9kFQIWqUHbnNAoO9qOUdSJZ8Lo/pTO/df9LOPRaC Mi5UwvAf76zo+yTgq2SfJF8H/1bZBpNMF9l2cYlSAI4cNi8g8G8mKyFbcAIKAvMWDWNIrokZPvk WZfi006GzQLUMreDHlgvPoAHQR6swlIwMgU4PTenYbx2maBeFP4yDM2shprqH5efgWhPkC3iHPk RvAyMgta0HMXspV2xuSjVykf4gpQhSLn9IH8wQEEFSl1EDYRCODSG53q758dilQGrrbb+rCBnfY kmVQfYjjDVLZlnsNmBMr2f8NjjkMmxF0/gIgCfm9/6eZ85IfM1ArQ= X-Google-Smtp-Source: AGHT+IEKxb0M7maoGpx/RiMT0FhGt753M0U76sYSisy4o7s24Pcyr8H6ICzt+Fi34D6LxuLRgCrRDw== X-Received: by 2002:a2e:a363:0:b0:377:c556:68b7 with SMTP id 38308e7fff4ca-37a106d7154mr1905471fa.17.1761768682250; Wed, 29 Oct 2025 13:11:22 -0700 (PDT) Received: from [10.96.240.181] (mobile-access-b04858-250.dhcp.inet.fi. [176.72.88.250]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee09cc0fsm37147611fa.12.2025.10.29.13.11.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Oct 2025 13:11:20 -0700 (PDT) Message-ID: <7f2d2a9e-f135-4147-8781-417ad09b7360@gmail.com> Date: Wed, 29 Oct 2025 22:11:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Linux file permission for COPY TO SQL command To: pgsql-sql@lists.postgresql.org References: <8ABD45BB-37B7-4394-AB59-10BC1C25797F@gmail.com> <7d2f7e34-c724-4227-a1c2-8d5882a6a3d4@gmail.com> <2892301.1761767753@sss.pgh.pa.us> Content-Language: en-US From: =?UTF-8?Q?Roland_M=C3=BCller?= In-Reply-To: <2892301.1761767753@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I think the best solution is to use the psql '\copy' that works the same way as server-side COPY or COPY TO. in addition, the output is always stored in the client machine regardless whetehr the server is in localhost, remote or inside a container. postgres=# \copy (SELECT * FROM pg_class) to /home/MYACCOUNT/Desktop/OUT COPY 420 postgres=# \! ls -ltr /home/MYACCOUNT/Desktop/OUT -rw-rw-r-- 1 MYACCOUNT MYACCOUNT 49291 Oct 29 22:06 /home/MYACCOUNT/Desktop/OUT On 10/29/25 21:55, Tom Lane wrote: > 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+  4 kaj kaj     4096 Oct 27 22:36 fd >> The SQL command which tries to write to the file is this: >> copy (select key from xcg where add=false) 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. You may want a client-side facility such as psql's \copy. > > regards, tom lane > >