如何从Mac上的终端关闭开放端口? [英] How do I close an open port from the terminal on the Mac?
本文介绍了如何从Mac上的终端关闭开放端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从Java类打开了端口#5955,以便从客户端进行通信.完成后如何关闭该端口?以及哪个命令可以告诉我端口是打开还是关闭?
I opened port #5955 from a java class to comunicate from a client. How do i close this port after I am done? and also which command can show me if port open or closed?
推荐答案
-
找出占用您要释放的端口号(例如5955)的进程ID(PID)
Find out the process ID (PID) which is occupying the port number (e.g., 5955) you would like to free
sudo lsof -i :5955
使用其PID杀死当前正在使用该端口的进程
Kill the process which is currently using the port using its PID
sudo kill -9 PID
这篇关于如何从Mac上的终端关闭开放端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文