Centos 查看进程的几条命令

1. ps -ef | grep java

表示查看所有进程里 CMD 是 java 的进程信息

2. ps -aux | grep java

-aux 显示所有状态

3. kill -9 [PID]

-9 表示强迫进程立即停止

4. lsof -i:8080 查看8080端口占用情况

 

其它:

1. netstat

netstat -nat | grep 3306

2. lsof

lsof -n -P -i TCP -s TCP:LISTEN

-n 表示主机以ip地址显示

-P 表示端口以数字形式显示,默认为端口名称

-i 意义较多,具体 man lsof, 主要是用来过滤lsof的输出结果

-s -i 配合使用,用于过滤输出

3. telnet

telnet 127.0.0.1 3306 

4. nc

nc  -w 10 -n -z 127.0.0.1 1990-1999

-w 10  表示等待连接时间为10

-n 尽量将端口号名称转换为端口号数字

-z 对需要检查的端口没有输入输出,用于端口扫描模式

127.0.0.1  需要检查的ip地址

1990-1999  可以是一个端口,也可以是一段端口

 返回结果为开放的端口, 如本例中的 1997 1998 端口

https://my.oschina.net/foreverich/blog/402252

5. 查看占用端口并杀死

http://blog.csdn.net/guoguo1980/article/details/2324454

lsof -n -P -i TCP -s TCP:LISTEN

kill 进程id

原文地址:https://www.cnblogs.com/SapphireCastle/p/6395129.html