惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
N
Netflix TechBlog - Medium
C
Check Point Blog
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
I
InfoQ
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
腾讯CDC
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
V
V2EX
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
B
Blog

博客园 - ABeen

[Database] Mongodb 分片集群 [Linux] vim状态栏配置 [Linux] Centos 添加开机启动脚本 [Linux] Docker 镜像及容器自动化思路 [Linux]Docker 容器时间与宿主机同步 [Linux] Tomcat java.lang.OutOfMemoryError: Java heap space [Linux] Nginx 反向代理配置 http headers 带下划线fields转发 [Linux] 非云环境的Ubuntu主机如何关闭Cloud-init [DataBase] MySql 查看实时日志 [Misc] ZSH 常用快捷键 [Database] MAC MySQL中文乱码问题 [Misc] python 开发vim 插件初步测试 [Tools] 多媒体视频处理工具FFmpeg [Linux] Ubuntu Server18 python3.7 虚拟环境 [Linux] 树莓派编译python3.7.4 [Linux] TMUX Python版本设置 Linux 批量杀进程的命令 arm树莓派Raspbian 下安装selenium+chrome 树莓派Raspbian系统密码
mac 终端查看端口命令
ABeen · 2019-06-23 · via 博客园 - ABeen

查看 端口所在线程 lsof -i:8080

mac-abeen:spider abeen$ lsof -i:8080
COMMAND  PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Python  5651 abeen    9u  IPv4 0xb1d20b318d3e65ed      0t0  TCP *:http-alt (LISTEN)
Python  5651 abeen   10u  IPv6 0xb1d20b3187b23fed      0t0  TCP *:http-alt (LISTEN)

查看mac终端端口命令 netstat -AaLlnW (相当于linux的 netstat -lntp)

mac-abeen:spider abeen$ netstat -AaLlnW
Current listen queue sizes (qlen/incqlen/maxqlen)
Socket           Flowhash Listen         Local Address         
b1d20b319398e96d        0 0/0/1          127.0.0.1.56987        
b1d20b3193a0ec6d        0 0/0/128        127.0.0.1.56966        
b1d20b318df39fed        0 0/0/1          127.0.0.1.56899        
b1d20b31957a896d        0 0/0/10         127.0.0.1.12227        
b1d20b31957aa5ed        0 0/0/1          127.0.0.1.56906        
b1d20b3193e05fed        0 0/0/10         127.0.0.1.12384        
b1d20b3188c06fed        0 0/0/128        127.0.0.1.56882        
b1d20b31958bfc6d        0 0/0/1          127.0.0.1.56870        
b1d20b3187b23fed        0 0/0/128        *.8080                                        
b1d20b318d3e65ed        0 0/0/128        *.8080                 
b1d20b3187b22ead        0 0/0/128        *.49204                                       
b1d20b318aea45ed        0 0/0/128        *.49204                
b1d20b3187b2232d        0 0/0/70         *.33060                
b1d20b3187b228ed        0 0/0/128        *.3306                 
b1d20b3187b28c6d        0 0/0/128        *.22                   
b1d20b3187b2346d        0 0/0/128        *.22  

查看端口是否被占用


mac-abeen:spider abeen$ sudo lsof -i :8080
Password:
COMMAND  PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Python  5651 abeen    9u  IPv4 0xb1d20b318d3e65ed      0t0  TCP *:http-alt (LISTEN)
Python  5651 abeen   10u  IPv6 0xb1d20b3187b23fed      0t0  TCP *:http-alt (LISTEN)


mac-abeen:spider abeen$ netstat -anp tcp | grep 8080
tcp4       0      0  192.168.0.100.58080    120.221.156.99.443     ESTABLISHED
tcp6       0      0  *.8080                 *.*                    LISTEN     
tcp4       0      0  *.8080                 *.*                    LISTEN   

结束占用端口的所有进程

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