本节内容:
![](https://img-blog.csdnimg.cn/img_convert/7f9ddbbc50c486190322d7140519e85f.png)
一、进程查看操作
1、ps命令
ps - report a snapshot of the current processes.
一个查看当前进程快照的命令
常用:ps aux(如下)
![](https://img-blog.csdnimg.cn/img_convert/776f788f4acbcf3bf75c48acac976596.png)
2、管道命令
管道命令符:|
把前面一个命令的输出送给后面的命令作为输入 -->进程和进程之间通信的方式 -->传递数据
举例:ps -aux | less -N 查看进程信息并通过less分页展示
3、grep命令
grep, egrep, fgrep - print lines matching a pattern
输出匹配的内容
![](https://img-blog.csdnimg.cn/img_convert/c60a87318917ecf8fef55d51689214dd.png)
二、文件查看
1、more和less命令
more - file perusal filter for crt viewing
less - opposite of more
区别:1、less可以按上下方向键来显示上下内容,而more不能通过上下方向键控制显示
2、less不必读整个文件,加载速度比more更快
3、less退出后shell不会留下刚显示的内容,而more退出后会在shell上留下刚显示的内容
2、head和tail命令
head - output the first part of files
tail - output the last part of files
head:默认显示前十行
![](https://img-blog.csdnimg.cn/img_convert/77351f647db8b4951d86fd46b94a6b14.png)
tail:默认显示末尾十行
![](https://img-blog.csdnimg.cn/img_convert/3905fac24a81fc23ec33ac8f85f922e1.png)
3、sed命令
sed - stream editor for filtering and transforming text
全称stream editor,是一种流编辑器,用于过滤和转换文本。
用法:
1:得到连续的行数
![](https://img-blog.csdnimg.cn/img_convert/48ebb8b7f4876a65c32c72f683ab0c3f.png)
2:得到不连续的行数
![](https://img-blog.csdnimg.cn/img_convert/475afd5c86b1b7aee1d7d642c4060bef.png)