Linux查看进程、端口号的各种用法

1.根据进程名称查看进程号

ps -ef|grep redis

结果如下:

[root@instance-xfl1djr7 ~]# ps -ef|grep redis
root     23297     1  0 Jun12 ?        00:01:33 /usr/bin/redis-server 127.0.0.1:6378

2.根据进行id查看占用端口号

netstat -anp|grep 23297

结果如下:

[root@instance-xfl1djr7 ~]# netstat -anp|grep 23297
tcp        0      0 127.0.0.1:6378          0.0.0.0:*               LISTEN      23297/

3.查看防火墙开放的端口号

iptables -L -n

结果如下:

[root@instance-xfl1djr7 ~]# iptables -L -n
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:22
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:21
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80

发布了48 篇原创文章 · 获赞 13 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_37825371/article/details/91872706