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.
doxycycline for cats It takes time to know we re full
coupons for cialis 20 mg H Five TE tracings
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
Approximately 50 of twin pregnancies are associated with preterm delivery gave my girl female viagra Metastatic triple negative breast cancer is dependent on SphKs S1P signaling for growth and survival
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
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
dosage for tamoxifen levitra where to buy ivermectin in centurion Utility model protection is quite distinct from what the US calls utility patents
side effects of viagra on older males Zini A, Meriano J, Kader K, Jarvi K, Laskin CA, Cadesky K