Linux 命令行中查看系统信息的综合指南138

在 Linux 操作系统中,获取有关系统配置、硬件信息、进程活动和资源利用率等详细信息至关重要。通过利用各种命令行工具,系统管理员和用户可以深入了解系统并诊断问题。

本指南将深入探讨 Linux 中用于查看系统信息的常用命令,并提供实用示例,帮助您高效地获取所需信息。以下是涵盖的命令:

unamehostnamecat /proc/versionlscpufreevmstattoppsdfiostatnetstatifconfigiwconfigdmesglast

1. uname

用途:获取有关系统内核和操作系统版本的详细

示例:```$ uname -aLinux hostname 4.15.0-1046-aws #21 SMP Wed May 29 17:37:23 UTC 2019 x86_64 GNU/Linux```

2. hostname

用途:获取系统的名称

示例:```$ hostnamehostname```

3. cat /proc/version

用途:显示内核版本和编译选项

示例:```$ cat /proc/versionLinux version 4.15.0-1046-aws (builder@) (gcc version 7.3.1 20180324 (Red Hat 7.3.1-5)) #21 SMP Wed May 29 17:37:23 UTC 2019```

4. lscpu

用途:显示 CPU 信息,包括架构、内核数量和缓存大小

示例:```$ lscpuArchitecture: x86_64CPU op-mode(s): 32-bit, 64-bitByte Order: Little EndianAddress sizes: 39 bits physical, 48 bits virtualCPU(s): 24On-line CPU(s) list: 0-23Thread(s) per core: 1Core(s) per socket: 1Socket(s): 2NUMA node(s): 1Vendor ID: GenuineIntelCPU family: 6Model: 63Model name: Intel(R) Xeon(R) Gold 5218R CPU @ 2.10GHzStepping: 4CPU max MHz: 2700.0000CPU min MHz: 1200.0000BogoMIPS: 4200.00Virtualization: VT-xL1d cache: 32 KiBL1i cache: 32 KiBL2 cache: 1024 KiBL3 cache: 25600 KiBNUMA node0 CPU(s): 0-23Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid ssbd cx16rt avx xsave avx2 rdseed lwp f16c rdpid fsgsbase tsc_adjust bmi1 avx512f avx512dq rdtscp_msb ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hwp_pkg_resp avx512ifma avx512er msr_safe avx512cd clwb sha_ni rdpid3```

5. free

用途:显示系统内存使用情况

示例:```$ free total used free shared buff/cache availableMem: 15669672 4664552 9907920 3392 1048228 10878496Swap: 2096516 0 2096516```

6. vmstat

用途:显示虚拟内存统计信息,包括页面交换和 CPU 使用情况

示例:```$ vmstat 1procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 494400 9892284 1048228 10843840 0 0 0 0 149 3262 0 0 0 0 0```

7. top

用途:交互式地显示正在运行的进程和资源使用情况

示例:```$ toptop - 17:31:10 up 24 days, 11:49, 2 users, load average: 0.28, 0.35, 0.36Tasks: 170 total, 1 running, 169 sleeping, 0 stopped, 0 zombie%Cpu(s): 0.3 us, 0.3 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stMiB Mem : 15669.6 total, 10016.2 free, 1975.7 used, 4647.7 buff/cacheMiB Swap: 2096.5 total, 2096.5 free, 0.0 used. 10295.2 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 1 root 20 0 3318600 39240 29020 S 0.0 0.3 0:05.75 systemd 102 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 103 root 20 0 0 0 0 S 0.0 0.0 0:00.33 rcu_gp 104 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_par_gp 105 root 20 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 106 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/0 107 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/1 108 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/2 109 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/3 110 root RT 0 0 0 0 S 0.0 0.0 0:00.00 watchdog/4 111 root RT 0 0 0 0 S 0.0 0.0

2024-11-02


上一篇:深入浅出:OnePlus 3刷iOS系统背后的技术之旅

下一篇:iOS vs. Android: 深入剖析移动操作系统之间的差异