到昨天为止,把《Linux脚本攻略》看完了,全书有273页,老实说是最近少有的我能从头看到尾的书。evernote中我大概记了10个note,以下是从中抽选的一些笔记,之后有空的话还会加更多的。
按照CPU使用量排序(倒序)进程
1 |
ps –eo comm,pcpu —sort –pcpu | head |
ps -e 表示显示所有进程
ps -o 表示筛选显示的列,comm是可执行文件,pcpu是CPU使用量
ps –sort 表示排序依据,-pcpu表示按照CPU使用量倒排(+pcpu表示正排)
head表示截图头十行
kill相关
列出所有执行的信号
1 |
kill –l |
给指定的进程发送信号
1 |
kill –s SIGNAL process_id |
常见信号
- SIGINT 2 ctrl + c
- SIGKILL 9 强制退出
- SIGSTP 20 ctrl + z
which, whereis & whatis
1 2 3 4 5 |
which cmd # 打印命令位置 whereis cmd # 打印命令位置和手册位置 whatis cmd # 打印命令描述 apropos word # 按照关键字从手册中查找命令(?) |
系统参数相关
1 2 3 4 5 6 7 8 9 10 11 12 |
uname –n # 打印机器的域名 uname –a # 打印全部 uname –r # 内核版本 uname –m # 机器类型,i686, 64位等 cat /proc/cpuinfo # CPU 信息 cat /proc/cpuinfo | head –5 | tail –1 # 打印CPU型号 cat /proc/meminfo # 内存信息 cat /proc/meminfo | head –1 # 打印内存总量 cat /proc/partitions # 打印分区,或者fdisk -l lshw # 列出系统信息,包括PCI,USB等等 |