linux监听端口程序

## 标题监听mysql
  • ps -ef|grep mysql
    (中间那个mysql,才是你要找的。)
root       1404      1  0 11:26 ?        00:00:00 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/server/data/localhost.localdomain.pid
mysql      2521   1404  0 11:26 ?        00:00:11 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/www/server/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --open-files-limit=65535 --pid-file=/www/server/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root       4832   4216  0 11:50 pts/1    00:00:00 grep --color=auto mysql

https://www.hualigs.cn/image/62e8a3748267f.jpg

ps -ef | grep mysql是查看mysql状态的命令,本文介绍ps -ef|grep mysql命令组成详解。
ps
ps命令是Process Status的缩写,ps命令用来列出系统中当前运行的进程。ps命令提供进程的一次性的查看,它所提供的查看结果并不动态连续的;如果想对进程时间监控,应该用 top 工具。

ps参数说明:
-A  显示所有程序;
-e  此参数的效果和指定"A"参数相同;
-f  显示UID,PPIP,C与STIME栏位;

grep
grep命令是查找,grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。

中间的“|”
中间的|是管道命令 是指ps命令与grep同时执行。
ps -ef|grep mysql的意思是显示有关mysql的进程。

ps -ef |grep 进程名称

  • 杀死进程:kill -9 pid (不一定能终止,多来几次就可以了)
  • 系统终止myslq:systemctl stop mysql
  • 系统重启mysql:systemctl restart mysql

查看程序端口====>netstat -ntpl

[root@localhost xchen]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2378/dnsmasq        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1293/sshd           
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1308/cupsd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1975/master         
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN      3898/sshd: root@pts 
tcp        0      0 0.0.0.0:29435           0.0.0.0:*               LISTEN      2655/python         
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      4866/docker-proxy   
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      791/rpcbind         
tcp6       0      0 :::22                   :::*                    LISTEN      1293/sshd           
tcp6       0      0 ::1:631                 :::*                    LISTEN      1308/cupsd          
tcp6       0      0 ::1:25                  :::*                    LISTEN      1975/master         
tcp6       0      0 ::1:6010                :::*                    LISTEN      3898/sshd: root@pts 
tcp6       0      0 :::3306                 :::*                    LISTEN      4874/docker-proxy   
tcp6       0      0 :::111                  :::*                    LISTEN      791/rpcbind         
[root@localhost xchen]# 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值