You can use nmap to determine all the TCP/IP ports on which a remote server is listening. It isn’t usually an important tool in the home environment, but it can be used in a corporate environment to detect vulnerabilities in your network, such as servers running unauthorized network applications. It is a favorite tool of malicious surfers and therefore should be used to test external as well as internal servers under your control.
Here is an example of trying to do a scan using valid TCP connections (-sT) in the extremely slow “insane” mode (-T 5) from ports 1 to 5000.
# nmap -sT -T 5 -p 1-5000 192.168.1.153