linuxÔõôÉó²é¿ªÆôÁËÄÄЩ¶Ë¿Ú
linux¿ÉÒÔͨ¹ýÒÔÏÂÒªÁìÉó²é¿ªÆôÁ˵Ķ˿ڣº1¡¢Ê¹ÓÃnetstatÏÂÁî¡°netstat -tuln¡±£¬¸ÃÏÂÁÏÔʾËùÓÐÄ¿½ñ¼àÌýµÄtcpºÍudp¶Ë¿Ú£»2¡¢Ê¹ÓÃssÏÂÁî¡°ss -tuln¡±£¬ÓÃÓÚÏÔʾĿ½ñ¼àÌýµÄtcpºÍudp¶Ë¿Ú£»3¡¢Ê¹ÓÃlsofÏÂÁî¡°lsof -i¡±£¬½«ÏÔʾĿ½ñ·¿ªµÄÍøÂçÅþÁ¬ºÍ¼àÌýµÄ¶Ë¿Ú¡£
±¾½Ì³Ì²Ù×÷ϵͳ£ºLinux5.18.14ϵͳ¡¢Dell G3µçÄÔ¡£
ÔÚ Linux ÖУ¬Äã¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Éó²éϵͳÉÏ¿ªÆôÁËÄÄЩ¶Ë¿Ú£º
1¡¢Ê¹Óà netstat ÏÂÁ
netstat -tuln
µÇ¼ºó¸´ÖÆ
¸ÃÏÂÁÏÔʾËùÓÐÄ¿½ñ¼àÌýµÄ TCP ºÍ UDP ¶Ë¿Ú¡£ÆäÖУ¬
-t ÌåÏÖÏÔʾ TCP ¶Ë¿Ú£¬
-u ÌåÏÖÏÔʾ UDP ¶Ë¿Ú£¬
-l ÌåÏÖ½öÏÔʾ¼àÌý״̬µÄ¶Ë¿Ú£¬
-n ÌåÏÖÒÔÊý×ÖÐÎʽÏÔʾ¶Ë¿ÚºÅ¡£
2¡¢Ê¹Óà ss ÏÂÁ
ss -tuln
µÇ¼ºó¸´ÖÆ
´ËÏÂÁîÓë netstat ÀàËÆ£¬ÓÃÓÚÏÔʾĿ½ñ¼àÌýµÄ TCP ºÍ UDP ¶Ë¿Ú¡£ÆäÖУ¬
-t ÌåÏÖÏÔʾ TCP ¶Ë¿Ú£¬
-u ÌåÏÖÏÔʾ UDP ¶Ë¿Ú£¬
-l ÌåÏÖ½öÏÔʾ¼àÌý״̬µÄ¶Ë¿Ú£¬
-n ÌåÏÖÒÔÊý×ÖÐÎʽÏÔʾ¶Ë¿ÚºÅ¡£
3¡¢Ê¹Óà lsof ÏÂÁ
lsof -i
µÇ¼ºó¸´ÖÆ
´ËÏÂÁÏÔʾĿ½ñ·¿ªµÄÍøÂçÅþÁ¬ºÍ¼àÌýµÄ¶Ë¿Ú¡£ÆäÖУ¬
-i ÌåÏÖÖ»ÏÔʾÓëÍøÂçÏà¹ØµÄÐÅÏ¢¡£
ÕâЩÏÂÁÁгöϵͳÉÏÕýÔÚ¼àÌýµÄ¶Ë¿ÚÒÔ¼°ËüÃǵÄ״̬ºÍÏà¹ØÀú³ÌµÄÏêϸÐÅÏ¢¡£Çë×¢ÖØ£¬Ö´ÐÐÕâЩÏÂÁî¿ÉÄÜÐèÒª root »ò¾ßÓÐÊʵ±È¨ÏÞµÄÓû§²Å»ªÉó²éËùÓж˿ÚÐÅÏ¢¡£
Ï£ÍûÕâЩÏÂÁî¶ÔÄãÓÐËù×ÊÖú£¡ÈôÊÇÉÐÓÐÆäËûÎÊÌ⣬ÇëËæʱÌáÎÊ¡£
ÒÔÉϾÍÊÇlinuxÔõôÉó²é¿ªÆôÁËÄÄЩ¶Ë¿ÚµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡