postgres output query results to csv file from terminal permission denied code example
Example: permission denied postgres \copy csv command line
Give a permission to postgres user with chown command
like :
sudo chown postgres:postgres /home/username/Desktop/postgresData