Linux 系统检查指南118


Linux 操作系统以其稳定性、安全性、可定制性和开源特性而闻名。为了保持系统的正常运行,定期检查至关重要。本文将介绍各种命令和工具,帮助您全面检查您的 Linux 系统。

系统信息

uname -a 命令提供有关系统核心的信息,包括版本号、处理器类型和发行版。
$ uname -a
Linux hostname 5.15.0-43-generic #46~20.04.1-Ubuntu SMP Wed Aug 18 14:40:29 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

cat /etc/os-release 命令显示有关操作系统的发行版和版本的信息。
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="/"
SUPPORT_URL="/"
BUG_REPORT_URL="/ubuntu/"
PRIVACY_POLICY_URL="/legal/terms-and-conditions"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

hostnamectl 命令提供有关系统主机名、静态主机名、虚拟化系统和内核版本的信息。
$ hostnamectl
Static hostname: hostname
Icon name: computer-vm
Chassis: vm
Machine ID: a6f620e277a676719c82379413c7e2bb
Boot ID: dc7f48da1305424689dd853e9c0cb12d
Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux 5.15.0-43-generic
Architecture: x86-64

硬件信息

lspci 命令列出系统中的 PCI 设备及其详细信息。
$ lspci
00:00.0 Host bridge: Intel Corporation 5 Series/3400 Series Chipset PCIe Root Port 1
00:01.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCIe Root Port 2
00:14.0 USB controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller
00:16.0 Communication controller: Intel Corporation 5 Series/3400 Series Chipset HECI Controller
00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCIe Root Port 6
00:1d.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCIe Root Port 7
00:1f.0 ISA bridge: Intel Corporation HM55 Chipset LPC Interface Controller
00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset SATA RAID Controller
00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller
00:1f.6 Signal processing controller: Intel Corporation 5 Series/3400 Series Chipset Thermal Management Controller

lshw 命令提供有关系统硬件的详细报告,包括 CPU、内存、磁盘、网络设备和 USB 设备。
$ lshw
*-core
description: Core 0
product: Xeon E5-2630 v3
vendor: Intel Corp.
physical id: 0
bus info: cpu@0
version: Intel(R) Core(TM) i7-7940X CPU @ 3.10GHz
capacity: 6400 MHz
width: 64 bits
capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 sse3 ssse3 sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_prefetch_hint intel_pt ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt cqm tpr_shadow_pb spec_ctrl pku ospke vaes pcid_alloc
configuration: addressrange=0xa4000000-0xa8ffffff
resources: irq:56 memory:a4000000-a8ffffff
*-core
description: Core 1
product: Xeon E5-2630 v3
vendor: Intel Corp.
physical id: 1
bus info: cpu@0
version: Intel(R) Core(TM) i7-7940X CPU @ 3.10GHz
capacity: 6400 MHz
width: 64 bits
capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 sse3 ssse3 sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_prefetch_hint intel_pt ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt cqm tpr_shadow_pb spec_ctrl pku ospke vaes pcid_alloc
configuration: addressrange=0xa9000000-adffffff
resources: irq:57 memory:a9000000-adffffff

进程信息

ps aux 命令显示系统中当前正在运行的所有进程,包括它们的 PID、用户、CPU 使用率、内存使用率、启动时间和命令行。
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 25880 4836 ? Ssl Aug19 0:10 /sbin/init
root 2 0.0 0.0 248 80 ? S Aug19 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Aug19 0:00 [migration/0]
root 5 0.0 0.0 0 0 ? S Aug19 0:00 [idle_cpu.0]
root 6 0.0 0.0 0 0 ? S Aug19 0:00 [idle_cpu.1]

top 命令提供有关系统资源使用的实时视图,包括 CPU 使用率、内存使用率、进程列表和系统活动。
$ top
top - 23:42:02 up 11 days, 4:38, 1 user, load average: 0.12, 0.10, 0.08
Tasks: 258 total, 1 running, 257 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.0 us, 0.3 sy, 0.0 ni, 98.6 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
MiB Mem : 15789.4 total, 8987.1 free, 6802.3 used, 2672.0 buff/cache
MiB Swap: 2047.9 total, 2047.9 free, 0.0 used.
PID USER PR NI VIRT RES SHR S %CPU %MEM

2024-12-31


上一篇:iOS 系统:移动操作系统的典范

下一篇:华为鸿蒙系统揭秘:移动操作系统的新篇章