You could run the command as:
pg_dumpall -D /var/lib/pgsql/data > test
where /var/lib/pgsql/data is the path to your postgres data directory. THIS VARIES BY VERSION. you may find data located in /usr/local/pgsql/data or somewhere else. Do a
find / -name data
and see if one of these two places shows up.
You can then set the PGDATA variable in your /etc/profile so that when a user logs in, the path will be permanently set. Also I recommend setting up variables for log, port, etc so you can refer to these in other operations such as using pg_ctl. For example, in my /etc/profile I added these lines:
Note that these are specific to my installation. You can do a
find / -name pgsql
to see where the log is located. Note that you will get back lots of folders named pgsql. You are looking for the one that is a log file so you have to use your head. Doing a
on the results can tell you which are files and which are folders. Then you can check the ones that are files to see which one is the log. Of course if you find a file in you /var/log named pgsql, your probably safe with that one [lol].
Once you get the variables set up in your /etc/profile, exit and log back in for them to tale effect. Test by doing a
and see if you end up in your postgress data directory