#cat /proc/version Linux version 4.15.0-1060-gcp (buildd@lcy01-amd64-028) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)) #64-Ubuntu SMP Thu Mar 26 03:21:15 UTC 2020
#cat /etc/issue Ubuntu 16.04.6 LTS \n \l
#lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial
CPU 信息
lscpu
推荐指数: ⭐⭐⭐⭐⭐
作用: 格式化地显示 CPU 架构、核心数、线程数、型号频率等,非常清晰。
cat /proc/cpuinfo
作用: 显示每个 CPU 核心的详细原始数据(内容较多,lscpu 其实就是整理了这个文件的内容)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 2
# cat /proc/cpuinfo 查看 CPU 信息 processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU @ 2.30GHz stepping : 0 microcode : 0x1 cpu MHz : 2300.000 cache size : 46080 KB
ps # displays processes for the current shell. ps -ef # Display every active process on a Linux system in generic (Unix/Linux) format. ps -aux # Display all processes in BSD format.
kill 和 pkill
kill 需要先找到进程 ID,再按 PID 结束进程:
1 2
ps aux | grep firefox kill 1234
pkill 可以直接按进程名匹配:
1
pkill firefox
这个命令要谨慎使用,因为默认是按进程名做模式匹配。更安全的写法是精确匹配:
1
pkill -x firefox
pkill -f 会匹配完整命令行,而不只是进程名。这在脚本进程里很有用:
1 2 3 4 5
user 1234 python /home/user/scripts/web_server.py --port 8080 user 5678 python /home/user/scripts/data_processor.py --input data.csv