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

    以前netstat这个命令经常用,但是用的真是稀里糊涂的,写下加深一下印象

    常见参数

    -a 显示多有的选项,默认是不监听listen的

    -t tcp

    -u udp

    -p 显示建立相关连接的程序名称 

    -n 把端口,username,域名 都显示成数组,不会根据ip在定位域名,所以速度会相对快点

    -l 仅显示监听

    -s 显示每个协议的相关统计

    如果是root启用的,普通用户是无法看到程序名称的

    [jimmy@xxx ~]$ netstat -altp
    (No info could be read for "-p": geteuid()=1000 but you should be root.)
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      -                   
    tcp        0      0 iZ258ugv6ktZ:ssh        220.181.165.11:56273    ESTABLISHED -                   
    tcp        0      0 iZ258ugv6ktZ:ssh        220.181.165.10:46172    ESTABLISHED -                   
    tcp        0    544 iZ258ugv6ktZ:ssh        220.181.165.7:51149     ESTABLISHED -                   
    tcp        0      0 iZ258ugv6ktZ:57580      110.75.102.62:http      ESTABLISHED -  
    [root@aliyun ~/]netstat -atlp 
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      867/sshd            
    tcp        0    384 iZ258ugv6ktZ:ssh        220.181.165.11:56273    ESTABLISHED 32210/sshd: root@pt 
    tcp        0      0 iZ258ugv6ktZ:ssh        220.181.165.10:46172    ESTABLISHED 32039/sshd: root@pt 
    tcp        0      0 iZ258ugv6ktZ:ssh        220.181.165.7:51149     ESTABLISHED 32120/sshd: root@pt 
    tcp        0      0 iZ258ugv6ktZ:57580      110.75.102.62:http      ESTABLISHED 11910/AliYunDun

    加 -n

    [root@aliyun ~/]netstat -atlpn
    Active Internet connections (servers and established)
    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      867/sshd            
    tcp        0    384 123.56.156.119:22       220.181.165.11:56273    ESTABLISHED 32210/sshd: root@pt 
    tcp        0      0 123.56.156.119:22       220.181.165.10:46172    ESTABLISHED 32039/sshd: root@pt 
    tcp        0      0 123.56.156.119:22       220.181.165.7:51149     ESTABLISHED 32120/sshd: root@pt 
    tcp        0      0 123.56.156.119:57580    110.75.102.62:80        ESTABLISHED 11910/AliYunDun

    watch -n 1 -d netstat -ant

    -n 周期(s)

    -d 高亮显示变动

  • 相关阅读:
    X 如何在mysql客户端即mysql提示符下执行操作系统命令
    X MySQL UNDO表空间独立和截断 ,mysql undo 的历史
    X Mysql5.7忘记root密码及mysql5.7修改root密码的方法
    X mysql密码的安全策略ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
    二分法查找
    elasticsearch API
    logstash的基础
    elasticsearch的基础
    Linux的进程管理
    Linux的网卡配置
  • 原文地址:https://www.cnblogs.com/bai-jimmy/p/4463576.html
Copyright © 2011-2022 走看看