How to check which service is running on which port

Introduction

To check service port numbers on a Unix based operating system, you may use one of the following methods…

  • netstat command

netstat command is used to display network related data. It is available on most Unix flavors including MacOS. The syntax may vary so it is recommended to check the manual (ex. man netstat or netstat -h). Here is an example syntax on Mac and Linux…

The output should be something like…

The output should be something like…

  • lsof command

lsof command is used to find which files are open by which process. It can be used to check port numbers as well. Let us have an example…

The output should be something like…

  • fuser command

fuser command is used to show which processes are using a specified file, file system, or unix socket. I personally used it but I could not get any useful results. Let me know if I am missing anything here in the comments section. Here is the syntax…

  • ss command

ss (i.e. Socket Statistics) command is available on Linux. It is used to display useful network socket information. Here is an example…

The output should be something like….

  • Port scanners

Depending on the operating system, we can use tools specifically developed to scan ports. For example, on Mac, we can use the Network Utility app. Take a look at the following screenshot.

I hope this summary was useful. Thanks for visiting.

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *