You can go to the data location of the database (the location of initdb after pgsql installation), where there is a postgresql.conf file, and search for port. If there is no # before "port = xxxx" (# is a comment and invalid), it means that this is the port number configured in your database. If there is #, the default port number is 5432.
In addition, there is a postmaste.pid under this path (assuming your database has been started). When you open it, you can see the port number of the started database.
The above content is the same for windows and linux versions.