Skip to content

Commit 1adf598

Browse files
committed
feat: add command/pwdx.md (#484)
1 parent fd20318 commit 1adf598

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

command/pwdx.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
pwdx
2+
===
3+
4+
用于显示指定进程的当前工作目录
5+
6+
## 内建命令
7+
8+
9+
### 概要
10+
11+
```shell
12+
pwdx [进程ID]
13+
```
14+
15+
### 参数说明
16+
17+
- `进程ID`:要查询的进程ID,可以使用 `ps` 命令查看。
18+
19+
## 示例
20+
21+
22+
下面示例中,使用 `ps` 命令查看 `nginx` 进程的信息,然后使用 `pwdx` 命令查询进程ID为 `5678` 的进程的当前工作目录。
23+
24+
```bash
25+
$ ps -ef | grep nginx
26+
# root 1234 1 0 10:00 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
27+
# www-data 5678 1234 0 10:01 ? 00:00:00 nginx: worker process
28+
29+
$ pwdx 5678
30+
# 5678: /var/www/html
31+
```
32+
33+
查看当前进程的工作目录:
34+
35+
```bash
36+
$ pwdx $$
37+
```
38+
39+
查看指定进程的工作目录:
40+
41+
```bash
42+
$ pwdx 1234
43+
```
44+
45+
批量查看多个进程的工作目录:
46+
47+
```bash
48+
$ ps aux | awk '{print $2}' | xargs pwdx
49+
```
50+
51+
结合其他命令,查看某个进程的工作目录和命令行:
52+
53+
```bash
54+
$ ps -p 1234 -o cmd | tail -n 1 | awk '{print $1}' | xargs pwdx
55+
```
56+
57+
查看所有进程的工作目录:
58+
59+
```bash
60+
$ ps -eo pid | xargs pwdx
61+
```

0 commit comments

Comments
 (0)