查看系统资源

vmstat -刷新秒数 -刷新次数:查看系统资源

  1. [root@iZwz91sneajs2ji49vo4wxZ iep-test.ca163.com]# vmstat 1 3
  2. procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
  3. r b swpd free buff cache si so bi bo in cs us sy id wa st
  4. 1 0 0 547804 200756 2988016 0 0 16 41 28 3 1 1 98 0 0
  5. 0 0 0 547968 200756 2988048 0 0 0 0 1055 1875 1 0 99 0 0
  6. 0 0 0 546216 200756 2988196 0 0 180 4 1410 2166 3 1 96 0 0

gmesggmesg | grep CPU:查看系统内核检测信息

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# dmesg | grep CPU
  2. [ 0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs
  3. [ 0.000000] setup_percpu: NR_CPUS:5120 nr_cpumask_bits:2 nr_cpu_ids:2 nr_node_ids:1
  4. [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
  5. [ 0.000000] RCU restricting CPUs from NR_CPUS=5120 to nr_cpu_ids=2.
  6. [ 0.096380] TAA: Vulnerable: Clear CPU buffers attempted, no microcode
  7. [ 0.096381] MDS: Vulnerable: Clear CPU buffers attempted, no microcode
  8. [ 0.149758] smpboot: CPU0: Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz (fam: 06, model: 55, stepping: 07)
  9. [ 0.250901] Performance Events: unsupported p6 CPU model 85 no PMU driver, software events only.
  10. [ 0.253747] MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details.
  11. [ 0.253748] TAA CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/tsx_async_abort.html for more details.
  12. [ 0.253749] Brought up 2 CPUs
  13. [356373.065138] CPU: 0 PID: 1393 Comm: php-fpm Not tainted 3.10.0-1127.19.1.el7.x86_64 #1
  14. [356447.086440] CPU: 1 PID: 3686 Comm: RuoyiScheduler_ Not tainted 3.10.0-1127.19.1.el7.x86_64 #1

free:查看内存资源

-b:以 B 为单位显示
-k:以 KB 为单位显示,默认值
-m:以 MB 为单位显示
-g:以 GB 为单位显示

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# free
  2. total used free shared buff/cache available
  3. Mem: 7862344 6562544 161052 51916 1138748 969428
  4. Swap: 0 0 0
  5. [root@iZwz91sneajs2ji49vo4wxZ ~]# free -g
  6. total used free shared buff/cache available
  7. Mem: 7 6 0 0 1 0
  8. Swap: 0 0 0
  9. [root@iZwz91sneajs2ji49vo4wxZ ~]# free -m
  10. total used free shared buff/cache available
  11. Mem: 7678 6407 156 50 1114 948
  12. Swap: 0 0 0

cat /proc/cpuinfo:查看 CPU 信息

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# cat /proc/cpuinfo
  2. processor : 0
  3. vendor_id : GenuineIntel
  4. cpu family : 6
  5. model : 85
  6. model name : Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz
  7. stepping : 7
  8. microcode : 0x1
  9. cpu MHz : 2500.000
  10. cache size : 36608 KB
  11. physical id : 0
  12. siblings : 2
  13. core id : 0
  14. cpu cores : 1
  15. apicid : 0
  16. initial apicid : 0
  17. fpu : yes
  18. ...

uptime:显示系统的启动时间和平均负载

与 top 命令的第一行信息一样

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# uptime
  2. 09:32:08 up 19 days, 21:36, 1 user, load average: 1.05, 1.07, 1.09

uname:查看系统与内核相关信息

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# uname
  2. Linux
  3. [root@iZwz91sneajs2ji49vo4wxZ ~]# uname -a
  4. Linux iZwz91sneajs2ji49vo4wxZ 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  5. [root@iZwz91sneajs2ji49vo4wxZ ~]# uname -r
  6. 3.10.0-1127.19.1.el7.x86_64
  7. [root@iZwz91sneajs2ji49vo4wxZ ~]# uname -s
  8. Linux

file /bin/ls:使用 file 查看系统命令的方式查看系统位数

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# file /bin/ls
  2. /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aaf05615b6c91d3cbb076af81aeff531c5d7dfd9, stripped

lsb_release -a:查看系统发行版本

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# lsb_release -a
  2. LSB Version: :core-4.1-amd64:core-4.1-noarch
  3. Distributor ID: CentOS
  4. Description: CentOS Linux release 7.8.2003 (Core)
  5. Release: 7.8.2003
  6. Codename: Core

lsof | more:查看系统中所有进程调用的文件

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# lsof | more
  2. COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  3. systemd 1 root cwd DIR 253,1 4096 2 /
  4. systemd 1 root rtd DIR 253,1 4096 2 /
  5. systemd 1 root txt REG 253,1 1628544 269422 /usr/lib/systemd/systemd
  6. systemd 1 root mem REG 253,1 20064 272678 /usr/lib64/libuuid.so.1.
  7. 3.0
  8. systemd 1 root mem REG 253,1 265576 266442 /usr/lib64/libblkid.so.1
  9. .1.0
  10. systemd 1 root mem REG 253,1 90248 265763 /usr/lib64/libz.so.1.2.7
  11. systemd 1 root mem REG 253,1 157424 266444 /usr/lib64/liblzma.so.5.
  12. 2.2
  13. systemd 1 root mem REG 253,1 23968 266498 /usr/lib64/libcap-ng.so.
  14. 0.0.0
  15. systemd 1 root mem REG 253,1 19896 265924 /usr/lib64/libattr.so.1.
  16. 1.0
  17. systemd 1 root mem REG 253,1 19248 272662 /usr/lib64/libdl-2.17.so
  18. systemd 1 root mem REG 253,1 402384 265943 /usr/lib64/libpcre.so.1.
  19. 2.0

lsof /sbin/init:查询某个文件被哪个进程调用

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# lsof /sbin/init
  2. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  3. systemd 1 root txt REG 253,1 1628544 269422 /usr/sbin/../lib/systemd/systemd

lsof -c php:查询某个进程调用了哪些文件

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# lsof -c php | more
  2. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  3. php 1804 root cwd DIR 253,1 4096 4595866 /www/wwwroot/education-new-serve/public
  4. php 1804 root rtd DIR 253,1 4096 2 /
  5. php 1804 root txt REG 253,1 10836280 3419670 /www/server/php/72/bin/php
  6. php 1804 root DEL REG 0,4 43760275 /dev/zero
  7. php 1804 root DEL REG 0,4 34266732 /dev/zero
  8. php 1804 root DEL REG 0,4 34267215 /dev/zero
  9. php 1804 root DEL REG 0,4 34267214 /dev/zero
  10. php 1804 root DEL REG 0,4 34267212 /dev/zero
  11. php 1804 root mem REG 253,1 5527040 3417061 /www/server/php/72/lib/php/extensions/no
  12. -debug-non-zts-20170718/fileinfo.so
  13. php 1804 root mem REG 253,1 402384 265943 /usr/lib64/libpcre.so.1.2.0
  14. php 1804 root mem REG 253,1 155744 265960 /usr/lib64/libselinux.so.1

lsof -u root:按照用户名查询用户调用了哪些文件

  1. [root@iZwz91sneajs2ji49vo4wxZ ~]# lsof -u root | more
  2. COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
  3. systemd 1 root cwd DIR 253,1 4096 2 /
  4. systemd 1 root rtd DIR 253,1 4096 2 /
  5. systemd 1 root txt REG 253,1 1628544 269422 /usr/lib/systemd/systemd
  6. systemd 1 root mem REG 253,1 20064 272678 /usr/lib64/libuuid.so.1.3.0
  7. systemd 1 root mem REG 253,1 265576 266442 /usr/lib64/libblkid.so.1.1.0
  8. systemd 1 root mem REG 253,1 90248 265763 /usr/lib64/libz.so.1.2.7
  9. systemd 1 root mem REG 253,1 157424 266444 /usr/lib64/liblzma.so.5.2.2
  10. systemd 1 root mem REG 253,1 23968 266498 /usr/lib64/libcap-ng.so.0.0.0
  11. systemd 1 root mem REG 253,1 19896 265924 /usr/lib64/libattr.so.1.1.0
  12. systemd 1 root mem REG 253,1 19248 272662 /usr/lib64/libdl-2.17.so
  13. systemd 1 root mem REG 253,1 402384 265943 /usr/lib64/libpcre.so.1.2.0
  14. systemd 1 root mem REG 253,1 2156240 265442 /usr/lib64/libc-2.17.so
  15. systemd 1 root mem REG 253,1 142144 265469 /usr/lib64/libpthread-2.17.so