Linux关于端口的操作
Linux
1. 查看端口被那个进程占用
lsof -i:xxxx(被占用的端口)
2. 关闭占用进程
kill -s 9 xxx(占用端口进程的Pid)
3. 开启防火墙
centos对端口的开启等操作都需要开防火墙的
systemctl start firewalld.service
systemctl enable firewalld.service
4. 开端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --reload
- 22 为需要开启的端口号。格式为:端口/通讯协议
- zone 作用域
- permanent 永久生效
5. 删除端口
firewall-cmd --zone= public--remove-port=80/tcp --permanent
Window
netstat -ano|findstr 8080
taskkill /pid 1268 /f
评论已关闭