On Wednesday 07 October 2009 07:32:46 am Boyd Stephen Smith Jr. wrote:
In <200910062151.41088.rschulz@sonic.net>, 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.
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... JSA -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org