In Linux:
Netstat command
[CPP]View Plaincopy
- [Email protected] ~]# Netstat-tulp
- Active Internet connections (only servers)
- Proto recv-q send-q Local address Foreign address State Pid/program Name
- Tcp 0 0 *:sunrpc *:* listen 2151/ rpcbind
- TCP 0 0 *:50000 *:* LISTEN 3542/DB2SYSC 0
- TCP 0 0 192.168.122.1:domain *:* LISTEN 2881/DNSMASQ
- tcp 0 0 *:ftp *:* LISTEN 2640/vsftpd
- tcp 0 0 *:ssh *:* LISTEN 2611/sshd
- TCP 0 0 Localhost:ipp *:* LISTEN 2343/CUPSD
- TCP 0 0 localhost:smtp *:* LISTEN 2660/sendmail
- tcp 0 0 *:38666 *:* LISTEN 2281/rpc.statd
- tcp 0 0 *:35339 *:* LISTEN 2281/rpc.statd
- tcp 0 0 *:sunrpc *:* LISTEN 2151/rpcbind
- tcp 0 0 *:ssh *:* LISTEN 2611/sshd
- TCP 0 0 Localhost:ipp *:* LISTEN 2343/CUPSD
- TCP 0 0 *:wbem-https *:* LISTEN 2905/cimservermain
- udp 0 0 *:kerberos-iv * :* 2087/portreserve
- Udp 0 0 *:sunrpc *:* 2151/rpcbind
- udp 0 0 *:rda *:* 2151/rpcbind
- udp 0 0 *:ipp *:* 2343/cupsd
- udp 0 0 *:rxe *:* 2281/rpc.statd
- Udp 0 0 *:ldaps *:* 2087/portreserve
- udp 0 0 *:d hcp-failover *:* 2087/portreserve
- udp 0 0 *:783 *:* 2087/portreserve
- udp 0 0 192.168.122.1:domain *:* 2881/dnsmasq
- Udp 0 0 *:bootps *:* 2881/dnsmasq
- udp 0 0 *:bootpc *:* 2312/dhclient
- udp 0 0 *: dhcp-failover2 *:* 2087/ portreserve
- udp 0 0 *:33375 *:* 2281/rpc.statd
- Udp 0 0 *:sunrpc *:* 2151/rpcbind
- udp 0 0 *:rda *:* 2151/rpcbind
- UDP 0 0 *:34398 *:* 2281/rpc.statd
Fuser command
[CPP]View Plaincopy
- [Email protected] ~]# fuser-v 22/tcp
- User Process number Permission command
- 22/tcp:root 2611 F .... sshd
- Root 7441 F .... sshd
lsof command
[CPP]View Plaincopy
- [Email protected] ~]# lsof-i:22
- COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
- sshd 2611 root 3u IPv4 16168 0t0 TCP *:ssh (LISTEN)
- sshd 2611 Root 4u IPv6 16172 0t0 TCP *:ssh (LISTEN)
- sshd 7441 root 3u IPv4 48583 0t0 TCP 192.168.1.105:ssh->192.168.1.100:61791 (established)
In Aix:
Netstat and Rmsock
[CPP]View Plaincopy
- (1) First use the Netstat command to view the port system kernel address (16 binary), such as the process of viewing SSH 22 port.
- # Netstat–aan |grep 22
- f1000600044c7398 TCP4 0 134.96.194.9.22 134.96.90.123.1797 established
- F1000600044e4b98 TCP4 0 0 *.22 * * LISTEN
- Including: f1000600044e4b98 TCP4 0 0 *.22 * * * LISTEN
- The behavior listens on port 22 port related information, f1000600044e4b98 is the system kernel address.
- (2) Call the Rmsock command to see the process number for that port:
- # Rmsock F1000600044e4b98 TCPCB (socket, TCPCB, INPCB, RIPCB or RAWCB)
- The socket 0x44e4808 is being held by Proccess 447250 (sshd). ---shows that the process number for Port 22 is 447250.
lsof command
[CPP]View Plaincopy
- # lsof-i:22
- COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
- sshd 107084 root 3u IPv4 0xf100070000a3a3b0 0t0 TCP *:ssh (LISTEN)
View that process takes up the port number (Linux vs. Aix)