2

www localhost

#Linux#Linux面试常用命令01

今天我们来学习 如何查看某个端口有没有被使用的命令:netstat

[root@localhost ~]# netstat -anp | grep :80

[root@localhost ~]#

1)如上显示 查看某个端口是否被占用命令格式为:【netstat -anp | grep :80】如果没有被查询出来说明没有被占用。

2)查询22端口,如下显示 即被占用了

[root@localhost ~]# netstat -anp | grep :22

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1041/sshd

tcp 0 52 192.168.1.8:22 192.168.1.5:51148 ESTABLISHED 32694/sshd: root@pt

tcp6 0 0 :::22 :::* LISTEN 1041/sshd

[root@localhost ~]#

3)如果某个端口被使用了,你又想使用这个端口怎么办,我们可以先把这个进程关闭

命令为:【kill -9 进程号】

如步骤的22端口 关闭进程命令即为:kill -9 32694 回车运行即可关闭。

两个进程可以占用一个端口?确实可以,IP版本不同就可以共用。如果先启动node(8080),再启动java,可以共用。但是先启动java(8080),再启动node就会选择8081避免端口重复。目测是由于localhost访问IPv4的服务会被覆盖,还要手动改hosts指定访问太麻烦。[思考]

[root@localhost ~]# firewall-cmd --reload

Error: COMMAND_FAILED: Direct: '/usr/sbin/iptables-restore -w -n' failed: iptables-restore v1.8.4 (nf_tables): interface name `ens192--destination' must be shorter than IFNAMSIZ (15)

Error occurred at line: 3

Try `iptables-restore -h' or 'iptables-restore --help' for more information.

[root@localhost ~]#

这样的报错,该如何解决啊?欢迎各位留言交流!

本文来自网络,不代表本站立场。转载请注明出处: https://tj.jiuquan.cc/a-2284777/
1
上一篇windows xp
下一篇 xps viewer

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: alzn66@foxmail.com

关注微信

微信扫一扫关注我们

返回顶部