Mailinglist Archive: opensuse (1589 mails)

< Previous Next >
Re: [opensuse] Address already in use
  • From: jsa <jsamyth@xxxxxxxxx>
  • Date: Wed, 7 Oct 2009 11:12:24 -0700
  • Message-id: <200910071112.24442.jsamyth@xxxxxxxxx>
On Wednesday 07 October 2009 07:32:46 am Boyd Stephen Smith Jr. wrote:
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

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

If there was a useless use of grep award you would have just won it.

And if there was a useless pedantic post award your name would be engraved
upon it.

What possible reason would you have for policing how others obtain information
without having to know each possible nuance of each possible control?

Somebody stoled my tag line, so now I have this rental...
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups