On Tue, Apr 24, 2001 at 11:46:50AM -0400, Marc Hughes wrote:
How can you determine what process has a tcp port open?
There are a few ways. # netstat -lpt # "-t" for TCP, "-u" for UDP, or both ... Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 *:mysql *:* LISTEN 7936/mysqld tcp 0 0 *:2583 *:* LISTEN 709/perl tcp 0 0 *:587 *:* LISTEN 644/sendmail: accep tcp 0 0 *:smtp *:* LISTEN 644/sendmail: accep [...snip...] I tend to use lsof since it's a bit more flexible: # lsof -i tcp COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME mon 709 root 3u IPv4 763 TCP *:2583 (LISTEN) mysqld 7936 root 3u IPv4 302589 TCP *:mysql (LISTEN) sendmail 644 root 4u IPv4 722 TCP *:smtp (LISTEN) sendmail 644 root 5u IPv4 723 TCP *:587 (LISTEN) [...snip...] or to find out everything running over tcp port 22: # lsof -i tcp:22 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME sshd 514 root 3u IPv4 558 TCP *:ssh (LISTEN) sshd 6338 root 4u IPv4 297933 TCP crystal:ssh->george:1418 (ESTABLISHED) ssh 7474 root 3u IPv4 301266 TCP crystal:620->salt:ssh (ESTABLISHED) -- Randomly Generated Tagline: "It's not you Bernie. I guess I'm just not used to being chased around a mall at night by killer robots." - Linda from the movie "Chopping Mall"