zoukankan      html  css  js  c++  java
  • netstat 查看本机开放端口

    root@kali:~# netstat -luntp

    Active Internet connections (only servers)

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1773/sshd       

    tcp6       0      0 :::22                   :::*                    LISTEN      1773/sshd       

    udp        0      0 0.0.0.0:57767           0.0.0.0:*                           1300/avahi-daemon: 

    udp        0      0 0.0.0.0:68              0.0.0.0:*                           2144/dhclient   

    udp        0      0 0.0.0.0:69              0.0.0.0:*                           869/inetd       

    udp        0      0 0.0.0.0:50255           0.0.0.0:*                           2144/dhclient   

    udp        0      0 0.0.0.0:5353            0.0.0.0:*                           1300/avahi-daemon: 

    udp6       0      0 :::16794                :::*                                2144/dhclient   

    udp6       0      0 :::60098                :::*                                1300/avahi-daemon: 

    udp6       0      0 :::5353                 :::*                                1300/avahi-daemon: 

    -l, --listening

           Show only listening sockets.  (These are omitted by default.)

    --tcp, -t

    --udp, -u

    --numeric , -n

           Show numerical addresses instead of trying to determine symbolic host,  port or user names

    -p, --program

           Show the PID and name of the program to which each socket belongs

    不加 -l 显示当前活跃的网络连接

    root@kali:~# netstat -untp

    Active Internet connections (w/o servers)

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

    tcp        0      0 192.168.1.107:22        192.168.1.103:58318     ESTABLISHED 2243/0 

    OSX 下查看端口占用情况

    netstat -ant | grep $port

    // 查看80端口被谁占用

    sudo lsof -i :80

    netstat -anp tcp | grep 80

    如下命令可以直接结束占用端口的所有进程:

    lsof -P | grep ':80' | awk '{print $2}' | xargs kill -9

    http://www.qinbin.me/mac%E4%B8%8B%E6%9F%A5%E7%9C%8B%E7%AB%AF%E5%8F%A3%E6%98%AF%E5%90%A6%E8%A2%AB%E5%8D%A0%E7%94%A8/

  • 相关阅读:
    简易sql拼接工具类(使用StringBuilder实现)
    缓存工具类(使用ConcurrentMap集合实现)
    properties文档读取工具类
    【Codeforces Round #655 (Div. 2)】A-D
    【2020 杭电多校第四场】Go Running 最小点覆盖
    【2020 杭电多校第四场】1002 Blow up the Enemy
    【2020 HDU 多校训练第三场 1007 Tokitsukaze and Rescue】暴力删边&最短路
    【2020杭电多校第二场】Total Eclipse 思维+并查集
    【2020HDU多校】Lead of Wisdom 暴力
    【CF-1371 C-E2】
  • 原文地址:https://www.cnblogs.com/hangj/p/4993145.html
Copyright © 2011-2022 走看看