zoukankan      html  css  js  c++  java
  • linux命令

    1. 查看linux中某个端口(port)是否被占用(netstat,lsof) 

    1)netstat -tunlp 会显示所有端口和所有对应的程序,用grep管道可以过滤出想要的关键字段.
    列一下22端口占用的程序 (会将所有有关22的列出来,包括不是端口为22的信息)
    [root@leiwan tmp]# netstat -tunlp |grep 22
    tcp        0      0 0.0.0.0:42957               0.0.0.0:*                   LISTEN      2230/rpc.statd      
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2443/sshd           
    tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2292/cupsd          
    tcp        0      0 :::22                       :::*                        LISTEN      2443/sshd           
    tcp        0      0 ::1:631                     :::*                        LISTEN      2292/cupsd          
    tcp        0      0 :::57609                    :::*                        LISTEN      2230/rpc.statd      
    udp        0      0 0.0.0.0:5353                0.0.0.0:*                               2211/avahi-daemon   
    udp        0      0 0.0.0.0:631                 0.0.0.0:*                               2292/cupsd          
    udp        0      0 0.0.0.0:37167               0.0.0.0:*                               2230/rpc.statd      
    udp        0      0 0.0.0.0:52291               0.0.0.0:*                               2211/avahi-daemon   
    udp        0      0 0.0.0.0:68                  0.0.0.0:*                               2207/dhclient       
    udp        0      0 0.0.0.0:710                 0.0.0.0:*                               2230/rpc.statd      
    udp        0      0 :::39834                    :::*                                    2230/rpc.statd

    [root@caiwutest ~]# netstat -tunlp | grep 8080
    tcp 0 0 :::8080 :::* LISTEN 4281/java

     2)查看某一端口的占用情况: lsof -i:端口号

    [root@caiwutest ~]# lsof -i:8080
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
    java 4281 root 46u IPv6 2053273 0t0 TCP *:webcache (LISTEN)

  • 相关阅读:
    hdu5714 拍照[2016百度之星复赛C题]
    hdu5715 XOR 游戏 [2016百度之星复赛D题]
    AFO
    BZOJ 3566 概率充电器
    BZOJ 3427 Bytecomputer
    BZOJ 4513 储能表
    BZOJ 3667 Miller_Rabin
    BZOJ 4557 侦察守卫
    BZOJ 3894 文理分科
    SUOI #69 奔跑的Aqua
  • 原文地址:https://www.cnblogs.com/wenlj/p/5624205.html
Copyright © 2011-2022 走看看