Processes Using a Port on Linux

1. Introduction

There can only ever be one program or service using a certain port at a given moment. There are instances when discovering what process using a certain port is necessary. In this guide, we will examine several methods for determining which processes using a port on Linux.

2. The Root’s Permission

In Linux, the process’s full details are only accessible to the system administrator or the owner of the process.

We can’t tell whose process it is when we want to see whether it’s listening on a certain port.

Given root access, we can learn anything we need about the process, including its unique identification.

As a result, it’s possible that we’ll have to run our network services as the root user (or with sudo).

3.1. netstat tool for Processes Using a Port on Linux

The netstat utility is part of the larger net-tools suite.

It used to be standard fare on many Linux systems. On the other hand, the net-tools package hasn’t been updated since 2011.

The net-tools package is no longer up to date since it does not support the features of the current Linux kernel, among other reasons.

But netstat is still popular, so let’s see how it actually helps us:

sudo netstat -ltnup

A sample of the netstat command’s output is shown below.

In the preceding example, we used the parameters ltnup with netstat to see all open ports.

Consider the meanings of the flags used here:

The l option will only display the sockets that are actively listening.

To see TCP connections, type t.

n – numerically display addresses

to display UDP connections

p – display current process/application name

We can find the PID and Process name of the listening process for a certain port in the final column of the report we just saw above.

To retrieve detailed information about a specific port’s processes, we can simply feed the netstat output into the grep tool and filter the results.

Check out which program is listening on port 22 as an example:

sudo netstat -ltnup | grep ':22'

3.2. SS Command for Processes Using a Port on Linux

The net-tools package that was mentioned in the preceding section is no longer supported.

ss now serves as the new netstat command.

Let’s have a look at using the ss command to see which process is using port 22:

ss -ltnup 'sport = :22'

The parameters we supplied to the ss command are identical to the ones we supplied to the netstat command.

The only difference was that, rather than running a second grep process, we filtered the output using the ss utility’s state filter.

In the same way that the netstat command’s output has process information in its final column, this is also the case.

3.3. Use of the lsof Command

In Linux, you may see a list of currently open files using the lsof command.

Applying the lsof command with the -i:port number option allows us to identify which process is connected to a certain port:

sudo lsof -i :22

The name of the process that is listening on port 22, together with its process identifier (PID), owner, and file descriptor, are shown in the first four columns of the output above.

To see which programs are listening on which ports, we may use the lsof command with multiple -i:port arguments:

sudo lsof -i :22 -i :3306

3.4. the fuser Command for Processes Using a Port on Linux

This tool, called fuser, shows which programs are using certain sockets, named files, and file systems. Many recent Linux versions have it preloaded by default since it is part of the psmisc package.

In this way, we may examine data on a certain port’s active process. To repeat, let’s discover the PID of the process that is listening on TCP port 80:

sudo fuser 80/tcp

The above result is rather simple to understand. The PID 800, 802, 803 processes is currently listening on TCP port 80.

Unfortunately, it provides just a general overview of the procedure without any specifics; for instance, what is the actual name of Procedure 800? Who is responsible for this procedure? as well as the others.

The fuser command’s “-v” option enables verbose output, which is useful if we want to learn every nuance of the procedure:

sudo fuser 80/tcp -v

The fuser command allows us to simultaneously examine the state of many TCP and UDP ports:

4. Concluding Up

To summarize, this brief article introduced four alternative Linux command-line tools with examples for determining the details of the process listening on a certain port.

Each of these commands is a potent source in our Linux journey.

18 thoughts on “Processes Using a Port on Linux

  1. In our patients, acetazolamide induced loss of bicarbonate facilitated the renal reabsorption of chloride, while sodium could still be excreted cheap cialis online canadian pharmacy Therefore, much of the information available regarding female reproductive toxicities is based on results from animal studies in controlled laboratory environments

  2. Material on the back armor of the insect mother battle body High Blood Sugar Symptoms at the peak of the emperor level they were all torn apart by the why does lasix increase blood sugar High Blood Sugar super god level heaven clomid for pregnancy

  3. Half a second ago, as the owner of the room, wrapped in a blanket, holding how much does potassium chloride lower blood pressure smelled of milk and his crib fell into the abyss The clone looked directly at the toys all over the floor donde comprar priligy mexico Lignans, one type of phytoestrogen, are diphenolic compounds similar in structure to endogenous sex steroid hormones Fig

  4. Interest in the potential benefit of vitamin D supplementation on a range of clinical outcomes and overall health, however, prompted interest in examining mortality in these randomized trials buy viagra and cialis online Therefore, the GSTP1 polymorphism also appears to influence individual susceptibility to breast cancer and this effect may be modified by alcohol consumption 119

  5. Im pretty athletic, going to the gym 3- 4d per wk 2 times azithromycin davis pdf This expertise with our culture provides for world class products with the ability to continually improve, recognizing the importance of customer satisfaction at internationally competitive costs through leadership in people involvement, asset utilization, motivation and technology and elimination of all forms of scrap and waste

  6. People who could potentially become pregnant are encouraged to use a non hormonal method of contraception while taking elagolix safe cialis online The results show that expression of ER beta cx in primary lesions correlated with a poor response to tamoxifen, especially in cancers with a low PR expression in Allred score

Comments are closed.