Linux系统资源查看
Posted Acumen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux系统资源查看相关的知识,希望对你有一定的参考价值。
以下Linux系统资源查看命令中,较常用的为vmstat 与 lsof
- vmstat [刷新延时 刷新次数]
1 ucm@ucm-Aspire-TC-606:~$ vmstat 1 5 2 procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- 3 r b 交换 空闲 缓冲 缓存 si so bi bo in cs us sy id wa st 4 0 0 0 4721680 294340 1586676 0 0 28 13 441 738 4 2 94 1 0 5 0 0 0 4721556 294348 1586676 0 0 0 280 1391 2388 2 0 96 1 0 6 0 0 0 4721416 294364 1586676 0 0 0 104 1410 2443 2 1 97 1 0 7 2 0 0 4721416 294364 1586716 0 0 0 0 2149 3443 2 1 97 0 0 8 0 0 0 4721416 294364 1586716 0 0 0 0 1430 2393 2 0 97 0 0 9 ucm@ucm-Aspire-TC-606:~$
- dmesg 内核自检信息
1 ucm@ucm-Aspire-TC-606:~$ dmesg | grep CPU 2 [ 0.000000] smpboot: Allowing 6 CPUs, 0 hotplug CPUs 3 [ 0.000000] setup_percpu: NR_CPUS:256 nr_cpumask_bits:256 nr_cpu_ids:6 nr_node_ids:1 4 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=6, Nodes=1 5 [ 0.000000] RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=6. 6 [ 0.006228] CPU: Physical Processor ID: 0 7 [ 0.006228] CPU: Processor Core ID: 0 8 [ 0.006229] mce: CPU supports 7 MCE banks 9 [ 0.167668] smpboot: CPU0: AMD FX(tm)-6300 Six-Core Processor (family: 0x15, model: 0x2, stepping: 0x0) 10 [ 0.168386] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter. 11 [ 0.168474] .... node #0, CPUs: #1 #2 #3 #4 #5 12 [ 0.182597] x86: Booted up 1 node, 6 CPUs 13 [ 1.579348] ledtrig-cpu: registered to indicate activity on CPUs 14 [ 1.580211] microcode: CPU0: patch_level=0x0600081f 15 [ 1.580215] microcode: CPU1: patch_level=0x0600081f 16 [ 1.580222] microcode: CPU2: patch_level=0x0600081f 17 [ 1.580228] microcode: CPU3: patch_level=0x0600081f 18 [ 1.580236] microcode: CPU4: patch_level=0x0600081f 19 [ 1.580244] microcode: CPU5: patch_level=0x0600081f 20 ucm@ucm-Aspire-TC-606:~$
- free 查看内存
- cat /proc/cpuinfo 查看CPU信息
- uptime 查看系统启动时间与平均负载
- uname [option]
options:
-a 查看系统所有的相关信息
-r 查看内核版本
-s 查看内核名称
1 ucm@ucm-Aspire-TC-606:~$ uname -a 2 Linux ucm-Aspire-TC-606 4.8.0-28-generic #30-Ubuntu SMP Fri Nov 11 14:03:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 3 ucm@ucm-Aspire-TC-606:~$ uname -r 4 4.8.0-28-generic 5 ucm@ucm-Aspire-TC-606:~$ uname -s 6 Linux 7 ucm@ucm-Aspire-TC-606:~$
- 判断系统位数
file 外部命令,会显示该命令是多少位的命令,进而知道系统位数.
1 ucm@ucm-Aspire-TC-606:~$ file /bin/ls 2 /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=eca98eeadafddff44caf37ae3d4b227132861218, stripped 3 ucm@ucm-Aspire-TC-606:~$
- 系统发行版
1 ucm@ucm-Aspire-TC-606:~$ lsb_release -a 2 No LSB modules are available. 3 Distributor ID: Ubuntu 4 Description: Ubuntu 16.10 5 Release: 16.10 6 Codename: yakkety 7 ucm@ucm-Aspire-TC-606:~$
- 列出系统打开或使用的文件信息
lsof [option]
options:
-c 字符串 只列出以字符串开头的进程打开的文件
-u 用户名 只列出某个用户的进程打开的文件
-p PID 列出某个PID进程打开的文件
eg:
查询系统中所有进程调用的文件
ucm@ucm-Aspire-TC-606:~$ lsof | more
查询某个系统文件被哪个进程调用
ucm@ucm-Aspire-TC-606:~$ lsof /sbin/init COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME systemd 1280 ucm txt REG 8,1 1038896 11276594 /lib/systemd/systemd ucm@ucm-Aspire-TC-606:~$
查看httpd进程调用啦哪些文件
ucm@ucm-Aspire-TC-606:~$ lsof -c httpd
按照用户名,查询某个用户的进程调用的文件名
ucm@ucm-Aspire-TC-606:~$ lsof -u root
以上是关于Linux系统资源查看的主要内容,如果未能解决你的问题,请参考以下文章