Specific methods:
Lsof -i: port number |grep "(listening)"
-i is used to find files related to the network. The ":"symbol is required to indicate that you are looking for a port. Port_number is the port number you are looking for. For example, if you want to find out whether there is a program occupying oracle's listening port 152 1, you can use lsof-I: 152 1 | grep. If a program has been occupied, the second field printed below is the process id of the program, and the first field is the name of the process.
If you only have losf -i :port_number, you may find many applications, but these applications don't actually occupy your designated port, and these ports are only connected to this port of this machine or other machines. So grep "(listening), because a port can only be occupied by a program, so this method is more reliable.