• [Linux]常用命令之【netstat/ps/lsof/ss/kill/】


    查看指定端口/服务所占用的端口

    netstat

    查看指定端口的占用情况

    [root@zunyi91 ~]# netstat -antp | grep 9876
    tcp        0      0 0.0.0.0:9876                0.0.0.0:*                   LISTEN      50264/java
    

    lsof

    root@kylin-sdc153:/opt/govern/govern_1/domains/mydomain/logs# sudo lsof -i:6888
    COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
    java    64812 root  100u  IPv4 4135639      0t0  TCP *:6888 (LISTEN)
    

    ss -lnp

    root@kylin-sdc153:/opt/govern/govern_1/domains/mydomain/logs# ss -lnp | grep 6888
    tcp    LISTEN     0      512       *:6888                  *:*                   users:(("java",pid=64812,fd=100))
    

    ps

    root@kylin-sdc153:/opt/govern/govern_1/domains/mydomain/logs# ps -ef
    UID        PID  PPID  C STIME TTY          TIME CMD
    ...
    root     70066     2  0 8月03 ?       00:00:00 [kworker/61:0]
    root     70139     2  0 8月03 ?       00:00:00 [kworker/84:2]
    root     70146     2  0 8月03 ?       00:00:00 [kworker/91:2]
    ...
    
    root@kylin-sdc153:/opt/govern/govern_1/domains/mydomain/logs# ps -ef | grep 6888
    root     66251 64699  0 10:05 pts/4    00:00:00 grep --color=auto 6888
    
    root@kylin-sdc153:/opt/govern/govern_1/domains/mydomain/logs# ps -ef | grep apusic
    root     64713 60453  0 09:59 pts/3    00:00:00 /bin/sh ./startapusic
    root     64812 64713 77 09:59 pts/3    00:04:04 /usr/bin/java -Djava.endorsed.dirs=/opt/govern/govern_1/lib/endorsed -Dcom.apusic.domain.home=/opt/govern/govern_1/domains/mydomain -server -Djava.net.preferIPv4Stack=true -Djava.security.egd=file:/dev/./urandom -Xms1024m -Xmx2048m -XX:MaxPermSize=512m -javaagent:/opt/sefon-secure/secure-agent.jar -classpath .:/opt/govern/govern_1/classes:/opt/govern/govern_1/...
    2.0.0.jar:/opt/govern/govern_1/lib/ext/*.zip/opt/govern/govern_1/domains/mydomain/lib/*.zip:/opt/govern/govern_1/domains/mydomain/lib/*.jar: com.apusic.server.Main -root /opt/govern/govern_1
    ...
    

    杀掉指定进程ID的进程

    kill

    [杀掉指定PID的进程]
    kill -9 <PID>
    

    Windows OS中类似的命令

    • tasklist netstat
    netstat -ano | findstr 8080
    
    • taskkill
    taskkill -F -PID <PID>
    taskkill -F -IM java.exe
    

    推荐文献

  • 相关阅读:
    origin 8.5 曲线拟合,延长曲线范围
    赤手空拳编写C#代码
    Vmware 10安装MAC OS X 10.9备忘
    Contest 1445
    Contest 1428
    Contest 1435
    Contest 991
    CSP-SJX2019 解题报告
    【BZOJ4817】【SDOI2017】树点染色
    codeforce 804B Minimum number of steps
  • 原文地址:https://www.cnblogs.com/johnnyzen/p/13438074.html
Copyright © 2020-2023  润新知