What Process Is Listening on a Given Port in Linux?

Knowing which processes are running on your Linux operating system can help protect you from security risks and system vulnerabilities, including processes listening on open ports. Keep track of the running processes and the users associated with them using Linux commands that list system details. Understanding how to use the Linux commands will help keep you in control of the processes that your system is running.

  1. Netstat Command

    • The netstat command is a utility that helps you monitor your network status, including which ports on your network have active connections or applications listening on the port. The basic netstat command to list all ports with listening applications is "netstat --listening." This returns a list of the active ports on your computer. Identify the port you want program details on from this list.

    Netstat Program Flag

    • Add a program flag at the end of your netstat command to list the port identification number and the name of the program that is currently listening on that port. The netstat command to view the listening ports with the active program names is formatted as "netstat --listening --programs." The last column of the return data will format the process identification number and program name separated by a slash, such as "PID/program."

    LSOF

    • When the program tag fails on your netstat command, or you need a different approach to identify the program associated with a port number, the lsof command returns program information for the port number you list in the command parameters. For example, to check port 80, enter "lsof -i :80" and review the return data. The first field lists the program associated with that process. If the first field shows Apache, the Apache Web server is listening on the port in question.

    Process Identification from PID

    • If you have a process identification number, the "ls" command will produce details about the process. Enter "ls -l /proc/processid/exe." For example, if you are looking for details about process number 1436, the command should appear as "ls -l /proc/1436/exe" to obtain process information. The data returned by the command will provide the name of the user account that launched the process as well as the process name in question.

Related Searches:

References

Comments

Related Ads

Featured