linux查看服务器系统信息,查看linux服务器系统
- 综合资讯
- 2024-09-30 05:13:16
- 5

***:主要涉及查看Linux服务器系统信息。在Linux中查看服务器系统信息有多种方式,如使用命令行工具。像“uname -a”可查看内核版本等基本系统信息,“cat...
***:主要讲述查看Linux服务器系统信息。在Linux中查看服务器系统信息是一项重要操作。可以通过多种命令来实现,如“uname -a”可查看内核版本等基本系统信息,“cat /etc/redhat - release”(针对Red Hat系)能查看发行版本等。这些操作有助于管理员了解服务器的硬件架构、内核版本、发行版等关键信息,从而进行系统维护、故障排查、软件兼容性评估等工作。
《Linux服务器系统查看全攻略》
在Linux环境下,查看服务器系统信息是系统管理和维护的重要任务,以下是一些常用的方法来获取服务器系统的各类关键信息。
一、查看系统版本信息
1、使用lsb_release -a
命令
- 这是查看Linux发行版相关信息的一个非常实用的命令,当在终端输入lsb_release -a
后,会显示诸如Distributor ID
(发行版的标识,如Ubuntu、CentOS等)、Description
(发行版的详细描述)、Release
(发行版的版本号)和Codename
(发行版的代号)等信息,在Ubuntu系统中,可能会显示如下信息:
```
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
```
2、查看/etc/issue
或/etc/os - release
文件
- 在许多Linux系统中,/etc/issue
文件包含了系统的版本和名称信息,可以使用cat /etc/issue
命令查看,例如在某些基于Red Hat的系统中,可能会看到类似“Red Hat Enterprise Linux Server release 7.9 (Maipo)”的信息。
- 而/etc/os - release
是一个更现代、结构化的文件,包含了更多关于操作系统的信息,使用cat /etc/os - release
命令,它以键值对的形式呈现信息,如NAME="CentOS Linux"
、VERSION="7 (Core)"
等。
二、查看系统内核信息
1、使用uname
命令
- 输入uname -a
命令可以查看系统内核的详细信息,输出结果包含内核名称(如Linux)、主机名、内核版本号、内核编译日期等信息。
```
Linux server1 5.4.0 - 80 - generic #90 - Ubuntu SMP Fri Jul 9 22:49:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```
- “5.4.0 - 80 - generic”就是内核版本号,“x86_64”表示系统的硬件架构。
2、查看/proc/version
文件
- 使用cat /proc/version
命令可以查看内核版本以及编译内核时使用的GCC版本等信息。
```
Linux version 5.4.0 - 80 - generic (buildd@lcy01-amd64 - 032) (gcc version 9.3.0 (Ubuntu 9.3.0 - 17ubuntu1~20.04)) #90 - Ubuntu SMP Fri Jul 9 22:49:44 UTC 2020
```
三、查看系统硬件信息
1、查看CPU信息
- 使用lscpu
命令可以获取CPU的详细信息,这包括CPU的架构(如x86_64)、CPU的核心数(Core(s) per socket
)、线程数(Thread(s) per core
)等。
```
Architecture: x86_64
CPU op - mode(s): 32 - bit, 64 - bit
Byte Order: Little Endian
CPU(s): 4
On - line CPU(s) list: 0 - 3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Stepping: 10
CPU MHz: 2394.484
BogoMIPS: 4788.96
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
```
2、查看内存信息
- 使用free -m
命令可以查看系统内存的使用情况,以兆字节(MB)为单位,输出结果包括总内存(total
)、已使用内存(used
)、空闲内存(free
)、共享内存(shared
)、缓冲/缓存内存(buff/cache
)等。
```
total used free shared buff/cache available
Mem: 8192 3000 1000 100 4192 4000
Swap: 2048 500 1548
```
- 还可以查看/proc/meminfo
文件获取更详细的内存信息,如MemTotal
(系统总的物理内存大小)、MemFree
(空闲的物理内存大小)、Buffers
(用于块设备的缓存内存大小)等,使用cat /proc/meminfo
命令查看。
3、查看磁盘信息
- 使用fdisk -l
命令可以查看系统的磁盘分区情况。
```
Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x332d3d33
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
```
- 使用df -h
命令可以查看磁盘的使用情况,以人类可读的格式(如KB、MB、GB等)显示。
```
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 10G 28G 26% /
tmpfs 4.0G 0 4.0G 0% /dev/shm
```
四、查看系统服务和进程信息
1、查看系统服务状态
- 在基于Systemd的系统(如许多现代的Linux发行版)中,可以使用systemctl
命令,要查看httpd
服务(如果安装了的话)的状态,可以使用systemctl status httpd
命令,输出结果会显示服务是否正在运行、是否已启用开机自启等信息,以及最近的日志信息。
- 在基于SysVinit的系统中,可以使用service
命令,如service httpd status
。
2、查看系统进程信息
- 使用ps -ef
命令可以查看系统中的所有进程信息,输出结果包括进程的用户(UID
)、进程ID(PID
)、父进程ID(PPID
)、启动时间、命令等信息。
```
UID PID PPID C STIME TTY STAT TIME CMD
root 1 0 0 Jun20? Ss 0:03 /sbin/init
root 2 0 0 Jun20? S 0:00 [kthreadd]
root 3 2 0 Jun20? S 0:00 [rcu_gp]
root 4 2 0 Jun20? S 0:00 [rcu_par_gp]
root 6 2 0 Jun20? S 0:00 [kworker/0:0H - kblockd]
root 9 2 0 Jun20? S 0:00 [mm_percpu_wq]
root 10 2 0 Jun20? S 0:00 [ksoftirqd/0]
root 11 2 0 Jun20? S 0:00 [rcu_sched]
root 12 2 0 Jun20? S 0:00 [migration/0]
root 13 2 0 Jun20? S 0:00 [idle_inject/0]
root 14 2 0 Jun20? S 0:00 [cpuhp/0]
root 15 2 0 Jun20? S 0:00 [cpuhp/1]
root 16 2 0 Jun20? S 0:00 [idle_inject/1]
root 17 2 0 Jun20? S 0:00 [migration/1]
root 18 2 0 Jun20? S 0:00 [rcu_sched]
root 19 2 0 Jun20? S 0:00 [ksoftirqd/1]
root 20 2 0 Jun20? S 0:00 [mm_percpu_wq]
root 21 2 0 Jun20? S 0:00 [kworker/1:0H - kblockd]
root 22 2 0 Jun20? S 0:00 [rcu_par_gp]
root 23 2 0 Jun20? S 0:00 [rcu_gp]
root 24 2 0 Jun20? S 0:00 [kdevtmpfs]
root 25 2 0 Jun20? S 0:00 [netns]
root 26 2 0 Jun20? S 0:00 [rps - dev - poll]
root 27 2 0 Jun20? S 0:00 [khungtaskd]
root 28 2 0 Jun20? S 0:00 [oom_reaper]
root 29 2 0 Jun20? S 0:00 [writeback]
root 30 2 0 Jun20? S 0:00 [kcompactd0]
root 31 2 0 Jun20? S 0:00 [ksmd]
root 32 2 0 Jun20? S 0:00 [khugepaged]
root 33 2 0 Jun20? S 0:00 [crypto]
root 34 2 0 Jun20? S 0:00 [kintegrityd]
root 35 2 0 Jun20? S 0:00 [kblockd]
root 36 2 0 Jun20? S 0:00 [blkcg_punt_bio]
root 37 2 0 Jun20? S 0:00 [tpm_dev_wq]
root 38 2 0 Jun20? S 0:00 [ata_sff]
root 39 2 0 Jun20? S 0:00 [scsi_eh_0]
root 40 2 0 Jun20? S 0:00 [scsi_eh_1]
root 41 2 0 Jun20? S 0:00 [scsi_tmf_0]
root 42 2 0 Jun20? S 0:00 [scsi_tmf_1]
root 43 2 0 Jun20? S 0:00 [vdpa_dev_wq]
root 44 2 0 Jun20? S 0:00 [xfsalloc]
root 45 2 0 Jun20? S 0:00 [xfs_mru_cache]
root 46 2 0 Jun20? S 0:00 [xfsdmapi]
root 47 2 0 Jun20? S 0:00 [xfs_buf_attach]
root 48 2 0 Jun20? S 0:00 [xfs_buf_dio_attach]
root 49 2 0 Jun20? S 0:00 [xfs_buf_iodone_attach]
root 50 2 0 Jun20? S 0:00 [xfs_buf_write_attach]
root 51 2 0 Jun20? S 0:00 [xfs_buf_read_attach]
root 52 2 0 Jun20? S 0:00 [xfs_log_attach]
root 53 2 0 Jun20? S 0:00 [xfs_eofblocks]
root 54 2 0 Jun20? S 0:00 [xfs_syncd]
root 55 2 0 Jun20? S 0:00 [xfs_mount]
root 56 2 0 Jun20? S 0:00 [xfs_force_shutdown]
root 57 2 0 Jun20? S 0:00 [xfs_quota]
root 58 2 0 Jun20? S 0:00 [xfs_kdmflush]
root 59 2 0 Jun20? S 0:00 [xfs_logd]
root 60 2 0 Jun20? S 0:00 [xfs_reclaim]
root 61 2 0 Jun20? S 0:00 [xfs_rtm]
root 62 2 0 Jun20? S 0:00 [xfs_freeze]
root 63 2 0 Jun20? S 0:00 [xfs_waitq]
root 64 2 0 Jun20? S 0:00 [xfs_trim]
root 65 2 0 Jun20? S 0:00 [xfs_iomap]
root 66 2 0 Jun20? S 0:00 [xfs_writeback]
root 67 2 0 Jun20? S 0:00 [xfs_log_writer]
root 68 2 0 Jun20? S 0:00 [xfs_log_write]
root 69 2 0 Jun20? S 0:00 [xfs_log_flusher]
root 70 2 0 Jun20? S 0:00 [xfs_log_force]
root 71 2 0 Jun20? S 0:00 [xfs_log_mount]
root 72 2 0 Jun20? S 0:00 [xfs_log_recover]
root 73 2 0 Jun20? S 0:00 [xfs_log_shutdown]
root 74 2 0 Jun20? S 0:00 [xfs_itable_lock]
root 75 2 0 Jun20? S 0:00 [xfs_icache_lock]
root 76 2 0 Jun20? S 0:00 [xfs_dqlock]
root 77 2 0 Jun20? S 0:00 [xfs_qmgr]
root 78 2 0 Jun20? S 0:00 [xfs_mru_cache_lock]
root 79 2 0 Jun20? S 0:00 [xfs_mru_cache_pinned]
root 80 2 0 Jun20? S 0:00 [xfs_mru_cache_pinned_lock]
root 81 2 0 Jun20? S 0:00 [xfs
本文链接:https://zhitaoyun.cn/73209.html
发表评论