记一次 Mac 端口占用程序查找经历

需求

找到80端口占用程序,并关闭它

步骤

  • 网上教程通常提供的命令,出现的结果太杂(无效)
    netstat -vanp tcp | grep 80

  • 查找 80 端口被占用的程序进程(有效)
    sudo lsof -i tcp:80

COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
httpd      93 root    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd     926 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13401 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13402 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)
httpd   13403 _www    4u  IPv6 0xb6f6a6b5914c0cff      0t0  TCP *:http (LISTEN)

发现是 httpd 命令

  • ps axu | grep 926
➜  web-server-laravel git:(master) ps axu | grep 926
root             84108   0.0  0.0  4309264      8   ??  SNs  22Nov18   0:00.01 /usr/libexec/periodic-wrapper monthly
root             29064   0.0  0.0  4309264      8   ??  SNs   7Nov18   0:00.02 /usr/libexec/periodic-wrapper weekly
root             24733   0.0  0.0  4309264      8   ??  SNs   6Nov18   0:00.09 /usr/libexec/periodic-wrapper daily
_www               926   0.0  0.0  4334768    952   ??  S     6Nov18   0:00.06 /usr/sbin/httpd -D FOREGROUND
  • 停用 httpd 服务
    sudo apachectl stop

参考资料

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容