File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 4
4
---
5
5
# 特别实用的shell命令
6
6
7
+ ## 查看已安装的软件列表
8
+ ::: code-group
9
+ ``` shell [dpkg]
10
+ # 查看已安装软件列表
11
+ dpkg --get-selections
12
+ # 列表很长,可以输出到文件中查看
13
+ dpkg --get-selections > dpkg_installed_list.txt
14
+ # 搜索特定软件包是否安装
15
+ dpkg -l | grep docker
16
+ ```
17
+ ``` shell [apt]
18
+ # 查看已安装软件列表
19
+ apt list --installed
20
+ # 列表很长,可以输出到文件中查看(输出的内容比dpkg更详细,包括软件,版本号,平台等信息)
21
+ apt list --installed > apt_installed_list.txt
22
+ # 搜索特定软件包是否安装
23
+ apt list --installed | grep docker
24
+ ```
25
+ :::
26
+
7
27
## 进程名查看进程信息
8
28
``` shell
9
29
ps -ef | grep docker
@@ -16,8 +36,30 @@ sudo netstat -lnp | grep id
16
36
17
37
## 杀死进程
18
38
``` shell
39
+ # 使用kill命令杀死进程
19
40
kill -s 9 id
41
+
42
+ # 安装killport,使用脚本杀死进程
43
+ curl -sL https://bit.ly/killport | sh
44
+ # 终端无法连接的话,可以先浏览器访问,复制脚本保存到本地install.sh中,手动执行安装
45
+ bash install.sh
46
+ # 添加killport到PATH中
47
+ sudo gedit /etc/profile
48
+ # 编辑,保存
49
+ export KILLPORT=" /home/muyi086/.local/bin"
50
+ export PATH=$KILLPORT :$PATH
51
+ # 使环境变量生效
52
+ source /etc/profile
53
+ # 杀死指定进程
54
+ killport 8080
55
+
20
56
```
57
+ ::: warning 注意
58
+ 报错 ` No service found using port `
59
+
60
+ 已提 ` issue ` : https://github.com/jkfran/killport/issues/43 ,等作者修复
61
+ :::
62
+
21
63
22
64
## 查找目录
23
65
``` shell
You can’t perform that action at this time.
0 commit comments