> For the complete documentation index, see [llms.txt](https://brownfly.gitbook.io/emergency-response/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brownfly.gitbook.io/emergency-response/linux/jin-cheng-yu-duan-kou.md).

# 进程与端口

## 端口

### 查看端口

```bash
$ netstat -antlp | more
```

查看`pid`对应的进程文件路径：

```bash
$ ls -l /proc/$PID/exe
# 或
$ file /proc/$PID/exe
```

### 查看连接

```bash
$ netstat -antlp | grep ESTABLISHED
$ netstat -antlp | grep LISTEN
```

## 进程

### 查看进程

```bash
$ ps aux | grep $PID | grep -v grep
```

### 隐藏进程查看

```bash
$ ps -ef | awk '{print}' | sort -n | uniq >1
$ ls /proc | sort -n |uniq >2
$ diff 1 2
```

### 查看相关文件和路径

```bash
$ lsof -p [PID]
$ pwdx [PID]
```
