Linux和Mac下查看端口占用、kill掉占用进程

查看命令:

lsof -i:port
如查看6073端口占用:
lsof -i:6073
结果:
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
python3.5 75899   test   7u  IPv4 0x931b4e8f4ec70d15      0t0  TCP localhost:directplay8 (LISTEN)

kill掉进程:

kill -9 75899  # 75899是进程id