How to retrieve or reset the password on postgresql on linux
If you want to reset your password you need to go to the pg_hba.conf file. You can do this by giving in the following command into Linux.

sudo subl /etc/postgresql/12/main/pg_hba.conf


After gaining access to the file you must change all local locations from Method md5 to trust so you can enter Postgresql without permission or without being asked for a password.
Then place the following command into Linux:

sudo /etc/init.d/postgresql restart


Subsequently, run the succeeding command to get into PostgreSQL:

sudo -u postgres psql


And last but not least run the common SQL Command to reset the password for User:

ALTER USER postgres with PASSWORD 'anewremembrablepassword';

Of course, you could also use another user than postgres if you considerably created one. Make sure you go back to the pg_hba.conf file to change the methods back to md5 so you always give in a password as for better security or leave it and never give in a password.
I hope I could be helpful in solving this matter.
Thanks!