I get this error while trying to dump database, i entered
linuxuser $ sudo su postgres linuxuser $ [sudo] password for linuxuser:... $ pg_dump -h localhost mydb
sudo su postgres doesn't change the current directory so you're still in linuxuser's home directory and postgres has no permission to write into it. Change to a different directory