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
postgres UserAs the other correct answers said, the folder in which you are trying save the backup does not have permissions assigned to the postgres user (operating system user account). The postgres user is the one running the backup utility. This user account was created during the Postgres installation process. You may have used a different name, but the default is postgres.
The solution is to either find or create a folder where the postgres user has read-write permissions.
In Mac OS X (Mountain Lion), I am able to create such a folder in the Finder.
postgres_backups.File > Get Info.Sharing & Permissions section.postgres user from the list.Privilege column, for the new postgres row, change the popup menu to Read & Write.Get Info window. Done.Now you can direct your Postgres backup files to that folder.

By the way, I use the pgAdmin app to do backups and restores. Control+click on the desired database and choose Backups…. The pgAdmin app was probably bundled with your Postgres installation.