How To Notice A Procedure Listening On A Specific Port Inwards Linux? Netstat In Addition To Lsof Ascendance Examples
In Linux, many times, you lot desire to find out the PID of a procedure which is listening on a port e.g. if multiple tomcat servers are running on a host as well as you lot direct keep to kill that process, but inwards social club to kill that procedure you lot require the procedure id, how produce you lot uncovering the PID of the tomcat listening on port 8080? There are many Linux commands to uncovering the procedure using a specific port, but I'll portion what I use. I ever work the netstat ascendence amongst -p option, which displays procedure id of the procedure listening on a port. Btw, netstat is non the solely ascendence to find all processes using a detail port, you lot tin too work the lsof command for the same purpose.
If you lot remember, nosotros direct keep used lsof before to uncovering all the processes accessing a file but it tin too live on used to uncovering all processes accessing a specific port.
You volition run into the event of both netstat and lsof commands inwards this article to uncovering the PID of procedure listening on a specific port inwards Linux.
On the related note, it's really of import for a Java developer to acquire well-nigh the Linux operating organization as well as commands. The to a greater extent than you lot know well-nigh the Linux Operating organization as well as unlike crunch e.g. bash, csh or ksh, the ameliorate you lot tin back upwardly your Java application.
That's why it's of import to bring together a class like Linux Command Line Basics, which provides an fantabulous introduction of essential crunch commands inwards Linux. It volition non solely assistance you lot to acquire well-nigh commutation of Linux OS but too all of import commands you lot require to operate efficiently inwards Linux.
hither you lot go, 25414 is the PID or procedure id of your tomcat server. Since tomcat is a Java spider web application it started amongst java ascendence as well as that's why you lot run into 25414/java.
Remember, if you lot are non logged inwards equally root or the user nether which your server is running, you lot mightiness run into next error:
No information could live on read for "-p": geteuid()=XXX but you lot should live on root
If you lot run into this error, thus only sudo equally the user which is running the tomcat. If you lot know how Linux works, then you lot tin solve this fault pretty chop-chop but if you lot don't thus you lot volition direct keep a difficult time.
only retrieve to -i option as well as colon (:) before the port like: 8080.
Btw, if you lot don't uncovering the lsof command inwards your PATH, search inwards /usr/sbin, to a greater extent than frequently /usr/sbin is non added into user's PATH. In that you lot tin run the ascendence equally shown below:
It volition display the same result.
Btw, if you lot similar the lsof ascendence as well as interested inwards learning its other application, you lot should depository fiscal establishment jibe my post service 10 ways to work the lsof ascendence inwards Linux. You tin too accept a hold back at below diagram yesteryear Julia Evans which effectively summarise the diverse options of lsof ascendence inwards Linux:
If you lot remember, nosotros direct keep used lsof before to uncovering all the processes accessing a file but it tin too live on used to uncovering all processes accessing a specific port.
You volition run into the event of both netstat and lsof commands inwards this article to uncovering the PID of procedure listening on a specific port inwards Linux.
On the related note, it's really of import for a Java developer to acquire well-nigh the Linux operating organization as well as commands. The to a greater extent than you lot know well-nigh the Linux Operating organization as well as unlike crunch e.g. bash, csh or ksh, the ameliorate you lot tin back upwardly your Java application.
That's why it's of import to bring together a class like Linux Command Line Basics, which provides an fantabulous introduction of essential crunch commands inwards Linux. It volition non solely assistance you lot to acquire well-nigh commutation of Linux OS but too all of import commands you lot require to operate efficiently inwards Linux.
Netstat ascendence to uncovering the PID of procedure listening on a port
So to uncovering the PID of your Java server listening on port 8080, you lot tin work the next Linux command:$ netstat -nap | grep 8080 (Not all processes could live on identified, non-owned procedure information volition non live on shown, you lot would direct keep to live on root to run into it all.) tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 25414/java
hither you lot go, 25414 is the PID or procedure id of your tomcat server. Since tomcat is a Java spider web application it started amongst java ascendence as well as that's why you lot run into 25414/java.
Remember, if you lot are non logged inwards equally root or the user nether which your server is running, you lot mightiness run into next error:
No information could live on read for "-p": geteuid()=XXX but you lot should live on root
If you lot run into this error, thus only sudo equally the user which is running the tomcat. If you lot know how Linux works, then you lot tin solve this fault pretty chop-chop but if you lot don't thus you lot volition direct keep a difficult time.
lsof ascendence event to uncovering the processes using a specific port
Here is the event of the lsof command to listing the procedure listening on a port.$ lsof -i :8080 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME coffee 25414 appuser 44u IPv4 3733348 TCP *:XXX (LISTEN)
only retrieve to -i option as well as colon (:) before the port like: 8080.
Btw, if you lot don't uncovering the lsof command inwards your PATH, search inwards /usr/sbin, to a greater extent than frequently /usr/sbin is non added into user's PATH. In that you lot tin run the ascendence equally shown below:
$ /usr/sbin/lsof -i :8080 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME coffee 25414 appuser 44u IPv4 3733348 TCP *:XXX (LISTEN)
It volition display the same result.
Btw, if you lot similar the lsof ascendence as well as interested inwards learning its other application, you lot should depository fiscal establishment jibe my post service 10 ways to work the lsof ascendence inwards Linux. You tin too accept a hold back at below diagram yesteryear Julia Evans which effectively summarise the diverse options of lsof ascendence inwards Linux:
Summary
Here is the summary of how to uncovering the procedure listening on a detail port inwards UNIX: grep, fifty-fifty if you lot only hand PID it volition fetch the occupation from netstat output thus I tin acquire the port on which a detail procedure is listening. Anyway, I volition demonstrate you lot a brace of to a greater extent than tricks to uncovering the port on which a detail port is listening inwards side yesteryear side tutorial.
Further Learning
Linux Command Line Basics
examples)How to telephone telephone REST spider web service from UNIX ascendence line? (command) 10 examples of grep ascendence inwards UNIX (examples) The deviation betwixt the soft link as well as difficult link inwards Linux? (answer) 10 examples of engagement ascendence inwards Linux (examples) How to get an IP address from a hostname as well as vice-versa inwards Linux (command) 10 examples of tar ascendence inwards UNIX (examples) How to delete empty files as well as directory inwards UNIX (solution) 10 examples of Vim inwards UNIX (examples) How to create, update as well as delete soft link inwards UNIX (command) 5 examples of form ascendence inwards Linux (examples) How to brand directory tree inwards ane command? (example) 10 examples of chmod command inwards UNIX (examples) UNIX ascendence to uncovering out how long a procedure is running? (answer) 5 examples of kill ascendence inwards Linux (examples) How to how long declaration of a procedure inwards Solaris (command) 10 examples of xargs command inwards Linux (examples) UNIX ascendence to uncovering the size of file as well as directory? (command) 10 tips to operate fast inwards UNIX? (tips)
Thanks for reading this article thus far. If you lot similar this Linux tutorial as well as uncovering the information useful delight portion amongst your friends as well as colleagues. If you lot direct keep whatsoever questions or feedback thus delight driblet a note.
Further Learning
Linux Command Line Basics
examples)
Thanks for reading this article thus far. If you lot similar this Linux tutorial as well as uncovering the information useful delight portion amongst your friends as well as colleagues. If you lot direct keep whatsoever questions or feedback thus delight driblet a note.


Komentar
Posting Komentar