From owner-freebsd-questions@FreeBSD.ORG Wed Apr 11 20:20:02 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F52E16A402 for ; Wed, 11 Apr 2007 20:20:02 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 5692E13C465 for ; Wed, 11 Apr 2007 20:19:52 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan@localhost [127.0.0.1]) by dan.emsphone.com (8.14.0/8.13.8) with ESMTP id l3BKJjeo018706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 Apr 2007 15:19:45 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.0/8.14.0/Submit) id l3BKJjJj018704; Wed, 11 Apr 2007 15:19:45 -0500 (CDT) (envelope-from dan) Date: Wed, 11 Apr 2007 15:19:45 -0500 From: Dan Nelson To: Bob Johnson Message-ID: <20070411201944.GE88325@dan.emsphone.com> References: <461A5D9E.2010501@aeternal.net> <200704101000.03164.jonathan@hst.org.za> <54db43990704111152w13707e45n1e0b6f436b69dc51@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54db43990704111152w13707e45n1e0b6f436b69dc51@mail.gmail.com> X-OS: FreeBSD 6.2-STABLE User-Agent: Mutt/1.5.14 (2007-02-12) Cc: Jonathan McKeown , freebsd-questions@freebsd.org Subject: Re: command to inentify the process that is listening in a port. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2007 20:20:02 -0000 In the last episode (Apr 11), Bob Johnson said: > On 4/10/07, Jonathan McKeown wrote: > >On Monday 09 April 2007 17:37, Martin Hudec wrote: > >> Siju George wrote: > >> > How Do you actually Identify what process is listening on a > >> > TCP/IP port? "nmap" does not usually give the right answer. > >> > There should be some command that can be run on the local host > >> > for identification right? > >> > >> man lsof > >> > >> 5:35pm [amber] ~# lsof -i @localhost:123 > >> COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME > >> ntpd 552 root 10u IPv4 0xc4c46000 0t0 UDP localhost:ntp > > > >Just out of interest, why do so many people recommend lsof, which is > >a port, when sockstat/fstat are in the base system and seem to cover > >the same ground? Am I missing something about lsof? > > Linux systems don't have sockstat, so people who got to FreeBSD via > Linux are used to lsof and they tend to continue using it. Same > result for those who read the many Linux howto websites. lsof can also go into more detail about the open handles (can display socket buffer sizes, for example), and has more filtering options. It also has a mode that generates easily machine-parsable output. For simple "what's listening on this port" questions, though, sockstat does just fine. -- Dan Nelson dnelson@allantgroup.com