码迷,mamicode.com
首页 > 系统相关 > 详细

查看那个进程占用了端口号(LINUX与AIX)

时间:2014-12-21 16:38:31      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:

在LINUX中:


netstat命令

  1. [root@limt ~]# netstat -tulp  
  2. Active Internet connections (only servers)  
  3. Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name     
  4. tcp        0      0 *:sunrpc                    *:*                         LISTEN      2151/rpcbind          
  5. tcp        0      0 *:50000                     *:*                         LISTEN      3542/db2sysc 0        
  6. tcp        0      0 192.168.122.1:domain        *:*                         LISTEN      2881/dnsmasq          
  7. tcp        0      0 *:ftp                       *:*                         LISTEN      2640/vsftpd           
  8. tcp        0      0 *:ssh                       *:*                         LISTEN      2611/sshd             
  9. tcp        0      0 localhost:ipp               *:*                         LISTEN      2343/cupsd            
  10. tcp        0      0 localhost:smtp              *:*                         LISTEN      2660/sendmail         
  11. tcp        0      0 *:38666                     *:*                         LISTEN      2281/rpc.statd        
  12. tcp        0      0 *:35339                     *:*                         LISTEN      2281/rpc.statd        
  13. tcp        0      0 *:sunrpc                    *:*                         LISTEN      2151/rpcbind          
  14. tcp        0      0 *:ssh                       *:*                         LISTEN      2611/sshd             
  15. tcp        0      0 localhost:ipp               *:*                         LISTEN      2343/cupsd            
  16. tcp        0      0 *:wbem-https                *:*                         LISTEN      2905/cimservermain    
  17. udp        0      0 *:kerberos-iv               *:*                                     2087/portreserve      
  18. udp        0      0 *:sunrpc                    *:*                                     2151/rpcbind          
  19. udp        0      0 *:rda                       *:*                                     2151/rpcbind          
  20. udp        0      0 *:ipp                       *:*                                     2343/cupsd            
  21. udp        0      0 *:rxe                       *:*                                     2281/rpc.statd        
  22. udp        0      0 *:ldaps                     *:*                                     2087/portreserve      
  23. udp        0      0 *:dhcp-failover             *:*                                     2087/portreserve      
  24. udp        0      0 *:783                       *:*                                     2087/portreserve      
  25. udp        0      0 192.168.122.1:domain        *:*                                     2881/dnsmasq          
  26. udp        0      0 *:bootps                    *:*                                     2881/dnsmasq          
  27. udp        0      0 *:bootpc                    *:*                                     2312/dhclient         
  28. udp        0      0 *:dhcp-failover2            *:*                                     2087/portreserve      
  29. udp        0      0 *:33375                     *:*                                     2281/rpc.statd        
  30. udp        0      0 *:sunrpc                    *:*                                     2151/rpcbind          
  31. udp        0      0 *:rda                       *:*                                     2151/rpcbind          
  32. udp        0      0 *:34398                     *:*                                     2281/rpc.statd   


fuser命令

  1. [root@limt ~]# fuser  -v 22/tcp  
  2.                      用户     进程号 权限   命令  
  3. 22/tcp:              root       2611 F.... sshd  
  4.                      root       7441 F.... sshd  


lsof命令

  1. [root@limt ~]# lsof -i:22  
  2. COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME  
  3. sshd    2611 root    3u  IPv4  16168      0t0  TCP *:ssh (LISTEN)  
  4. sshd    2611 root    4u  IPv6  16172      0t0  TCP *:ssh (LISTEN)  
  5. sshd    7441 root    3u  IPv4  48583      0t0  TCP 192.168.1.105:ssh->192.168.1.100:61791 (ESTABLISHED)  


在AIX中:


netstat和rmsock

  1. (1)先使用netstat命令查看端口系统内核地址(16进制),如查看ssh 22端口的进程。  
  2.  # netstat –Aan |grep 22  
  3. f1000600044c7398 tcp4       0     52  134.96.194.9.22  134.96.90.123.1797 ESTABLISHED  
  4. f1000600044e4b98 tcp4       0      0  *.22            *.*                LISTEN  
  5. 其中:f1000600044e4b98 tcp4       0      0  *.22            *.*                LISTEN  
  6. 行为侦听端口22端口相关信息, f1000600044e4b98为系统内核地址。  
  7. (2)调用rmsock命令查看该端口对应的进程号:  
  8. # rmsock  f1000600044e4b98 tcpcb  ( socket、tcpcb、inpcb、ripcb 或 rawcb)  
  9. The socket 0x44e4808 is being held by proccess 447250 (sshd). ---显示端口22的进程号为447250。  


lsof命令

    1. # lsof -i:22  
    2. COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME  
    3. sshd    107084 root    3u IPv4 0xf100070000a3a3b0      0t0 TCP *:ssh (LISTEN) 

查看那个进程占用了端口号(LINUX与AIX)

标签:

原文地址:http://www.cnblogs.com/yishujiayuan/p/4176682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!