共计 4564 个字符,预计需要花费 12 分钟才能阅读完成。
Linux下查看服务器信息常用命令记录
一、查看系统及内核版本
1.1 查看RHEL系统版本
[root@longxi ~]# cat /etc/redhat-release
Anolis OS release 7.9
1.2 查看RHEL及CentOS系统版本
[root@longxi ~]# cat /etc/centos-release
Anolis OS release 7.9
1.3 查看系统内核版本号、硬件架构、主机名称和操作系统类型
[root@longxi ~]# uname -a
Linux longxi 3.10.0-1160.83.1.0.1.an7.x86_64 #1 SMP Wed Feb 1 16:51:30 CST 2023 x86_64 x86_64 x86_64 GNU/Linux
二、查看服务器型号
2.1 通过过滤输出信息获取服务器制造商及具体型号信息
[root@longxi ~]# dmidecode|grep "System Information" -A9|egrep "Manufacturer|Product"
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
2.2 通过使用 -s 选项获取指定的信息
[root@longxi ~]# dmidecode -s system-manufacturer
Microsoft Corporation
[root@longxi ~]# dmidecode -s system-product-name
Virtual Machine
三、查看CPU相关信息
3.1 查看CPU型号:
[root@longxi ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
6 12th Gen Intel(R) Core(TM) i5-12400
3.2 查看物理CPU个数:
[root@longxi ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
1
3.3 查看每个物理CPU的核心数:
[root@longxi ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores : 3
3.4 查看逻辑CPU个数:
[root@longxi ~]# cat /proc/cpuinfo| grep "processor"| wc -l
6
四、查看内存相关信息
4.1 查看内存大小及使用情况
[root@longxi ~]# free -h
total used free shared buff/cache available
Mem: 3.7G 3.0G 194M 8.4M 516M 468M
Swap: 3.9G 8K 3.9G
Mem 行(第二行)是内存的使用情况。
Swap 行(第三行)是交换空间的使用情况。
total 列显示系统总的可用物理内存和交换空间大小。
used 列显示已经被使用的物理内存和交换空间。
free 列显示还有多少物理内存和交换空间可用使用。
shared 列显示被共享使用的物理内存大小。
buff/cache 列显示被 buffer 和 cache 使用的物理内存大小。
available 列显示还可以被应用程序使用的物理内存大小。
4.2 查看服务器上所有内存硬件信息
[root@longxi ~]# dmidecode -t memory
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.1.0 present.
Handle 0x0006, DMI type 16, 23 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 0 bytes
Error Information Handle: Not Provided
Number Of Devices: 2
Handle 0x0007, DMI type 17, 92 bytes
Memory Device
Array Handle: 0x0006
Error Information Handle: Not Provided
Total Width: Unknown
Data Width: Unknown
Size: 3968 MB
Form Factor: Unknown
Set: None
Locator: M0001
Bank Locator: None
Type: Unknown
Type Detail: Unknown
Speed: Unknown
Manufacturer: Microsoft Corporation
Serial Number: None
Asset Tag: None
Part Number: None
Rank: Unknown
Configured Memory Speed: Unknown
Minimum Voltage: Unknown
Maximum Voltage: Unknown
Configured Voltage: Unknown
Memory Technology: <OUT OF SPEC>
Memory Operating Mode Capability: None
Firmware Version: Not Specified
Module Manufacturer ID: Unknown
Module Product ID: Unknown
Memory Subsystem Controller Manufacturer ID: Unknown
Memory Subsystem Controller Product ID: Unknown
Non-Volatile Size: None
Volatile Size: None
Cache Size: None
Logical Size: None
Handle 0x000A, DMI type 17, 92 bytes
Memory Device
Array Handle: 0x0006
Error Information Handle: Not Provided
Total Width: Unknown
Data Width: Unknown
Size: 128 MB
Form Factor: Unknown
Set: None
Locator: M0002
Bank Locator: None
Type: Unknown
Type Detail: Unknown
Speed: Unknown
Manufacturer: Microsoft Corporation
Serial Number: None
Asset Tag: None
Part Number: None
Rank: Unknown
Configured Memory Speed: Unknown
Minimum Voltage: Unknown
Maximum Voltage: Unknown
Configured Voltage: Unknown
Memory Technology: <OUT OF SPEC>
Memory Operating Mode Capability: None
Firmware Version: Not Specified
Module Manufacturer ID: Unknown
Module Product ID: Unknown
Memory Subsystem Controller Manufacturer ID: Unknown
Memory Subsystem Controller Product ID: Unknown
Non-Volatile Size: None
Volatile Size: None
Cache Size: None
Logical Size: None
4.3 查看已经使用哪些插槽,每个插槽插入的内存大小
[root@longxi ~]# dmidecode|grep -A5 "Memory Device"|grep Size|grep -v Range
Size: 3968 MB
Size: 128 MB
五、查看磁盘相关信息
5.1 查看磁盘空间使用情况
[root@longxi ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.4M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/ao-root 50G 4.3G 46G 9% /
/dev/sda2 1014M 187M 828M 19% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/mapper/ao-home 72G 33M 72G 1% /home
tmpfs 379M 0 379M 0% /run/user/0
5.2 查看当前系统所有可用块设备的信息
[root@longxi ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 127G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 125.8G 0 part
├─ao-root 253:0 0 50G 0 lvm /
├─ao-swap 253:1 0 3.9G 0 lvm [SWAP]
└─ao-home 253:2 0 71.9G 0 lvm /home
sr0 11:0 1 1024M 0 rom
5.3 查看当前系统块设备相关UUID、文件系统类型等信息
[root@longxi ~]# blkid
/dev/sda1: SEC_TYPE="msdos" UUID="A261-71D5" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="62796c01-3e02-4b63-9ec0-821b55950ea5"
/dev/sda2: UUID="f6296d56-1712-4ed9-b1fd-0e26b7445681" TYPE="xfs" PARTUUID="70bb1eff-a9c5-497f-8e89-9d91bf73db56"
/dev/sda3: UUID="K7h6ea-gaqh-SSSn-wJbw-x2hE-w746-mGVGsb" TYPE="LVM2_member" PARTUUID="11ed028e-2cd4-4443-84c5-aedeee27efdc"
/dev/mapper/ao-root: UUID="685311d9-f4f9-4f47-874f-9e50af8e32c5" TYPE="xfs"
/dev/mapper/ao-swap: UUID="ba9a1869-0470-45f4-9d74-53cfacb02692" TYPE="swap"
/dev/mapper/ao-home: UUID="22d1b1e8-e490-49b1-b2de-f0a3346f74ac" TYPE="xfs"
六、查看网卡信息
6.1 查看所有网卡信息
[root@longxi ~]# ls /sys/class/net/
eth0 lo
6.2 查看虚拟网卡
[root@longxi ~]# ls /sys/devices/virtual/net/
lo
6.3 查看物理网卡
[root@longxi ~]# ls /sys/class/net/ | grep -v "`ls /sys/devices/virtual/net/`"
eth0
正文完