Mailinglist Archive: opensuse (1589 mails)

< Previous Next >
Re: [opensuse] Address already in use
  • From: "Boyd Stephen Smith Jr." <bss@xxxxxxxxxxxxxxxxx>
  • Date: Wed, 7 Oct 2009 09:32:46 -0500
  • Message-id: <200910070932.47375.bss@xxxxxxxxxxxxxxxxx>
In <200910062151.41088.rschulz@xxxxxxxxx>, Randall R Schulz wrote:
On Tuesday October 6 2009, Ricky Tompu Breaky wrote:
How can I know which TCP port number is being occupied? And how can
I know which service is using a certain port number? All I know only
turn off the firewall and doing "nmap -PN [FQDN-hostname]".

You can use the "lsof" command to associate IP addresses and port
numbers with the running process(es) that have that address / port
open.

To see all the IP ports in use with their process IDs (as root):

# lsof |egrep IP

lsof -i

Limiting it to IPv4:

# lsof |egrep IPv4

lsof -i4

Limiting it futher to TCP:

# lsof |egrep 'IPv4.*TCP'

lsof -i4tcp

And so on.

man 8 lsof

The process ID is the 2nd column and the program name is the 1st. Piping
through grep like that removes the column headers, but you can see them
with this:

# lsof |head -1

Wow. You do know that lsof has a multitude of ways to limit the output
itself, so that you get just IP, just IPv4, or just TCP connections AND the
headers output from a single command-line, without needing as second utility.

If there was a useless use of grep award you would have just won it.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@xxxxxxxxxxxxxxxxx ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
< Previous Next >
Follow Ups