Search This Blog

Showing posts with label netstat. Show all posts
Showing posts with label netstat. Show all posts

Thursday, May 24, 2012

Netstat linux command

netstat command is used to obtain network related information.

Such as
Routing table
Port information
Network interface information

let us explore netstat one by one.

1) How to display Routing table in linux?
2) How to find the port of particular application?
3) How Find out number of Machines (IP address) connected to Linux Server?

1) How to display Routing table in linux.

You can use netstat command to display routing table in linux.

#netstat -r

Wednesday, July 6, 2011

How to find the port of particular application?

Question : How do I find the port which is used by a particular application ?
Answer :
Consider Tomcat application is running on port 8080.
To check whether the Tomcat is running or not.

Initially you need to understand the output presented by
netstat -ntpl .
In above case Tomcat is using java as their process so i grep with java. Your application might be using different name.

#netstat -ntpl | grep java
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 6375/java
tcp 0 0 :::8009 :::* LISTEN 6375/java
tcp 0 0 :::8080 :::* LISTEN 6375/java

You should see at least one java process and you can use ps to identify if this is Tomcat.

# ps -ef | grep 6375
root 6375 1 0 May18 pts/2 00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root 9222 5091 0 18:29 pts/2 00:00:00 grep 6375

for killing the process just use.
kill -9

The above article is with reference to my question posted on below forum .
http://www.linuxquestions.org/questions/showthread.php?p=4010963&posted=1#post4010963

Wednesday, May 25, 2011

How Find out number of Machines (IP address) connected to Linux Server?

Use below Command to find out number of Machines connected to Server.

#netstat -nat | awk '{ print }' | cut -d: -f1 | sed -e '/^$/d' | uniq

Monday, March 28, 2011

All about Application and Port.

Check below url for finding port number associated with an application.
http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Above listing helps to identify which applications are using which port.

In Linux a command line utility netstat is used widely for identifying port.
a good articles over netstat can be found on below links.
http://www.thegeekstuff.com/2010/03/netstat-command-examples/