how to use netstat on a specific port in Linux












14















Guys i want to know if my specific port is running a server using netstat? how do i achieve that?










share|improve this question













migrated from stackoverflow.com May 31 '13 at 9:27


This question came from our site for professional and enthusiast programmers.














  • 1





    netstat -anp | grep portNumber

    – rags
    May 31 '13 at 5:47
















14















Guys i want to know if my specific port is running a server using netstat? how do i achieve that?










share|improve this question













migrated from stackoverflow.com May 31 '13 at 9:27


This question came from our site for professional and enthusiast programmers.














  • 1





    netstat -anp | grep portNumber

    – rags
    May 31 '13 at 5:47














14












14








14


3






Guys i want to know if my specific port is running a server using netstat? how do i achieve that?










share|improve this question














Guys i want to know if my specific port is running a server using netstat? how do i achieve that?







linux networking netstat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 31 '13 at 5:37







Monkey











migrated from stackoverflow.com May 31 '13 at 9:27


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com May 31 '13 at 9:27


This question came from our site for professional and enthusiast programmers.










  • 1





    netstat -anp | grep portNumber

    – rags
    May 31 '13 at 5:47














  • 1





    netstat -anp | grep portNumber

    – rags
    May 31 '13 at 5:47








1




1





netstat -anp | grep portNumber

– rags
May 31 '13 at 5:47





netstat -anp | grep portNumber

– rags
May 31 '13 at 5:47










3 Answers
3






active

oldest

votes


















15














You can use



netstat -pnlt | grep ':portno'


another option , you can use nmap tool for checking open ports on the server



nmap -sT -O localhost


Output



Starting nmap 3.55 ( http://www.insecure.org/nmap/ ) at 2004-09-24 13:49 EDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
Device type: general purpose


Netstat Example :



[root@krizna ~]# netstat -pnlt | grep ':80'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 1164/httpd





share|improve this answer
























  • and what part there in the results i can determine if it is a server?

    – Monkey
    May 31 '13 at 7:50











  • Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

    – krizna
    May 31 '13 at 8:14











  • It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

    – Kevin Keane
    Aug 27 '18 at 18:54



















2














use netstat -anp | grep portNumber






share|improve this answer
























  • so im getting list of many port 80 connections. how do i find the server port?

    – Monkey
    May 31 '13 at 6:10



















2














I think netstat -nat | grep port | grep LISTEN should do the trick.






share|improve this answer
























  • This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

    – Paul Tobias
    Mar 24 '16 at 8:17











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f602049%2fhow-to-use-netstat-on-a-specific-port-in-linux%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









15














You can use



netstat -pnlt | grep ':portno'


another option , you can use nmap tool for checking open ports on the server



nmap -sT -O localhost


Output



Starting nmap 3.55 ( http://www.insecure.org/nmap/ ) at 2004-09-24 13:49 EDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
Device type: general purpose


Netstat Example :



[root@krizna ~]# netstat -pnlt | grep ':80'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 1164/httpd





share|improve this answer
























  • and what part there in the results i can determine if it is a server?

    – Monkey
    May 31 '13 at 7:50











  • Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

    – krizna
    May 31 '13 at 8:14











  • It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

    – Kevin Keane
    Aug 27 '18 at 18:54
















15














You can use



netstat -pnlt | grep ':portno'


another option , you can use nmap tool for checking open ports on the server



nmap -sT -O localhost


Output



Starting nmap 3.55 ( http://www.insecure.org/nmap/ ) at 2004-09-24 13:49 EDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
Device type: general purpose


Netstat Example :



[root@krizna ~]# netstat -pnlt | grep ':80'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 1164/httpd





share|improve this answer
























  • and what part there in the results i can determine if it is a server?

    – Monkey
    May 31 '13 at 7:50











  • Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

    – krizna
    May 31 '13 at 8:14











  • It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

    – Kevin Keane
    Aug 27 '18 at 18:54














15












15








15







You can use



netstat -pnlt | grep ':portno'


another option , you can use nmap tool for checking open ports on the server



nmap -sT -O localhost


Output



Starting nmap 3.55 ( http://www.insecure.org/nmap/ ) at 2004-09-24 13:49 EDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
Device type: general purpose


Netstat Example :



[root@krizna ~]# netstat -pnlt | grep ':80'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 1164/httpd





share|improve this answer













You can use



netstat -pnlt | grep ':portno'


another option , you can use nmap tool for checking open ports on the server



nmap -sT -O localhost


Output



Starting nmap 3.55 ( http://www.insecure.org/nmap/ ) at 2004-09-24 13:49 EDT
Interesting ports on localhost.localdomain (127.0.0.1):
(The 1653 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
Device type: general purpose


Netstat Example :



[root@krizna ~]# netstat -pnlt | grep ':80'
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::80 :::* LISTEN 1164/httpd






share|improve this answer












share|improve this answer



share|improve this answer










answered May 31 '13 at 7:47









kriznakrizna

33114




33114













  • and what part there in the results i can determine if it is a server?

    – Monkey
    May 31 '13 at 7:50











  • Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

    – krizna
    May 31 '13 at 8:14











  • It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

    – Kevin Keane
    Aug 27 '18 at 18:54



















  • and what part there in the results i can determine if it is a server?

    – Monkey
    May 31 '13 at 7:50











  • Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

    – krizna
    May 31 '13 at 8:14











  • It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

    – Kevin Keane
    Aug 27 '18 at 18:54

















and what part there in the results i can determine if it is a server?

– Monkey
May 31 '13 at 7:50





and what part there in the results i can determine if it is a server?

– Monkey
May 31 '13 at 7:50













Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

– krizna
May 31 '13 at 8:14





Check the netstat example part, port :::80 is shown under local address which is LISTENING ( i mean open ).

– krizna
May 31 '13 at 8:14













It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

– Kevin Keane
Aug 27 '18 at 18:54





It is worth mentioning that the grep ':portno' may also pick up some IPv6 addresses that happen to contain that sequence. That can be a problem if you try to use this command in a script.

– Kevin Keane
Aug 27 '18 at 18:54













2














use netstat -anp | grep portNumber






share|improve this answer
























  • so im getting list of many port 80 connections. how do i find the server port?

    – Monkey
    May 31 '13 at 6:10
















2














use netstat -anp | grep portNumber






share|improve this answer
























  • so im getting list of many port 80 connections. how do i find the server port?

    – Monkey
    May 31 '13 at 6:10














2












2








2







use netstat -anp | grep portNumber






share|improve this answer













use netstat -anp | grep portNumber







share|improve this answer












share|improve this answer



share|improve this answer










answered May 31 '13 at 5:54









ragsrags

1215




1215













  • so im getting list of many port 80 connections. how do i find the server port?

    – Monkey
    May 31 '13 at 6:10



















  • so im getting list of many port 80 connections. how do i find the server port?

    – Monkey
    May 31 '13 at 6:10

















so im getting list of many port 80 connections. how do i find the server port?

– Monkey
May 31 '13 at 6:10





so im getting list of many port 80 connections. how do i find the server port?

– Monkey
May 31 '13 at 6:10











2














I think netstat -nat | grep port | grep LISTEN should do the trick.






share|improve this answer
























  • This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

    – Paul Tobias
    Mar 24 '16 at 8:17
















2














I think netstat -nat | grep port | grep LISTEN should do the trick.






share|improve this answer
























  • This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

    – Paul Tobias
    Mar 24 '16 at 8:17














2












2








2







I think netstat -nat | grep port | grep LISTEN should do the trick.






share|improve this answer













I think netstat -nat | grep port | grep LISTEN should do the trick.







share|improve this answer












share|improve this answer



share|improve this answer










answered May 31 '13 at 6:54







wizard




















  • This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

    – Paul Tobias
    Mar 24 '16 at 8:17



















  • This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

    – Paul Tobias
    Mar 24 '16 at 8:17

















This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

– Paul Tobias
Mar 24 '16 at 8:17





This is listing all ports, and then grep for listening ports. Instead it should just show the listening ports with -l instead of -a. And the question was not only about tcp ports so the -t option shouldn't be there.

– Paul Tobias
Mar 24 '16 at 8:17


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f602049%2fhow-to-use-netstat-on-a-specific-port-in-linux%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Plaza Victoria

Puebla de Zaragoza

Musa