---
title: "Linux下查看进程和端口信息【转】"
author: "bugyun"
date: "2020-02-25T11:46:13Z"
tags: []
categories: ["编程语言"]
slug: "linux"
draft: false
lastmod: "2020-02-25T11:46:13Z"
id: 2512598
url: "https://bugyun.iteye.com/blog/2512598"
---

转：[https://www.cnblogs.com/moy25/p/8668432.html](https://www.cnblogs.com/moy25/p/8668432.html)

 

1、根据进程名查看进程信息，以查看tomcat进程名为例，查看所对应的进程id为1095(或者使用： ps -aux | grep tomcat 查看占用内存等信息)

```
ps -ef | grep tomcat
```

![](https://images2018.cnblogs.com/blog/1256785/201803/1256785-20180329103011103-1775245323.png)

2、根据进程id查看进程占用端口，查看对应端口为8080（如果没有netstat命令，使用 yum  -y  install  net-tools安装）

```
netstat -nap | grep 1095
```

![](https://images2018.cnblogs.com/blog/1256785/201803/1256785-20180329130709770-155317304.png)

3、根据端口查看对应进程，查看占用8080端口的进程id，为1095

```
netstat -tunlp | grep 8080
```

![](https://images2018.cnblogs.com/blog/1256785/201803/1256785-20180329103750096-1103131624.png)

4、根据进程id查看进程信息，查看进程id为1095的进程信息

```
ps -ef | grep 1095
```

![](https://images2018.cnblogs.com/blog/1256785/201803/1256785-20180329103838967-521863701.png)

5、根据进程id杀死进程，杀死进程id为1095的进程

```
kill -9 1095
```

附：

[![复制代码](https://common.cnblogs.com/images/copycode.gif)]()

```
# window 查看占用端口80
netstat -aon|findstr "80"

# 查询进程号2448信息
tasklist|findstr "2448"

# 可以在任务管理器查询进程号并杀死
```

[![复制代码](https://common.cnblogs.com/images/copycode.gif)]()