Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Wed Aug 23, 2017 8:57 am


System administration, processes administration, jobs, cron, resources, limits, shells, ssh, telnet.

Author Message
mandrei99
  Post  Post subject: How to check if ssh/http daemon listens on TCP port in Linux using lsof & netstat  |  Posted: Mon Oct 17, 2011 9:17 am

Joined: Tue Aug 04, 2009 9:16 am
Posts: 245

Offline
 

How to check if ssh/http daemon listens on TCP port in Linux using lsof & netstat

To show listening sockets in Unix, the "netstat" utility can be used with different arguments, depending on the specific OS.

Man netstat:
Quote:
--numeric , -n
Show numerical addresses instead of trying to determine symbolic host, port or user names.
-e, --extend
Display additional information. Use this option twice for maximum detail.
[--tcp|-t]
-p, --program
Show the PID and name of the program to which each socket belongs.
[--udp|-u]
-l, --listening
Show only listening sockets. (These are omitted by default.)
[--all|-a]


Of course, "netstat -tulp" is enough to see if sshd/httpd are listening on their TCP ports, but I prefer the below example.

Checking SSH and Apache TCP ports in Linux using netstat:
Code:
# netstat -netpula | grep -E ":22|:80"
Proto Recv-Q Send-Q Local Address               Foreign Address             State       User       Inode      PID/Program name
tcp        0      0 :::80                       :::*                        LISTEN      0          78720642   5514/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      0          1688637    23490/sshd         


Displayed are the ID of the user that runs sshd & httpd, PID of the process and state (LISTEN).

Checking SSH and Apache TCP ports in Linux using lsof utility:
Code:
# lsof -Pni :22 -i :80
COMMAND   PID USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
httpd   17543  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   17815  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   18040  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   18046  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   18278  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   56459  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
sshd    61609 root    3u  IPv6 0xc35d3570      0t0  TCP *:22 (LISTEN)
sshd    61609 root    4u  IPv4 0xc35d3ae0      0t0  TCP *:22 (LISTEN)
httpd   75304 root    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)
httpd   78080  www    3u  IPv6 0xc35d3cb0      0t0  TCP *:80 (LISTEN)





Top
Display posts from previous:  Sort by  
E-mail friendPrint view

Topics related to - "How to check if ssh/http daemon listens on TCP port in Linux using lsof & netstat"
 Topics   Author   Replies   Views   Last post 
There are no new unread posts for this topic. How to check if ssh/http daemon listens on TCP port in FreeBSD using sockstat & lsof & netstat util

mandrei99

0

1268

Mon Oct 17, 2011 9:27 am

mandrei99 View the latest post

There are no new unread posts for this topic. How to identify each ethX device in Linux to what dual or quad port interface card it belongs to

mandrei99

0

717

Mon Jul 22, 2013 10:08 am

mandrei99 View the latest post

There are no new unread posts for this topic. How to list PCI devices in Linux - lspci

mandrei99

0

1284

Mon Jul 22, 2013 10:03 am

mandrei99 View the latest post

There are no new unread posts for this topic. Linux clear screen / terminal

mandrei99

2

4584

Wed Mar 04, 2015 8:52 am

Guest View the latest post

There are no new unread posts for this topic. Linux: List kernel supported filesystems

debuser

0

435

Tue Mar 10, 2015 5:45 pm

debuser View the latest post

There are no new unread posts for this topic. Linux: list block devices UUID

debuser

0

789

Tue Mar 10, 2015 5:46 pm

debuser View the latest post

There are no new unread posts for this topic. How to prevent Linux SSH client from disconnecting using ServerAliveInterval

mandrei99

0

14545

Fri Jan 09, 2015 8:26 pm

mandrei99 View the latest post

There are no new unread posts for this topic. Change default editor to VI in Debian Linux

mandrei99

0

637

Fri Jan 16, 2015 6:59 pm

mandrei99 View the latest post

There are no new unread posts for this topic. How to print filesystem super block information in Linux

mandrei99

0

6934

Mon Jul 08, 2013 6:56 am

mandrei99 View the latest post

There are no new unread posts for this topic. How to list the largest files in a directory in Linux/FreeBSD

mandrei99

0

540

Thu Jan 22, 2015 5:14 pm

mandrei99 View the latest post

 

Who is online
Users browsing this forum: No registered users and 0 guests
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
News News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO