FAIRYFAR-INTERNAL
 
  FAIRYFAR-INTERNAL  |  SITEMAP  |  ABOUT-ME  |  HOME  
Linux获取硬件与软件环境信息

获取主板制造商

snippet.bash
[yz@bogon ~]$ cat /sys/class/dmi/id/board_vendor
Dell Inc.

获取主板名称

snippet.bash
[yz@bogon ~]$ cat /sys/class/dmi/id/board_name
0DY2

获取计算机型号

snippet.bash
[yz@bogon ~]$ cat /sys/class/dmi/id/product_name
PowerEdge R740

获取机器硬件架构

snippet.bash
[yz@bogon ~]$ uname -m
x86_64

获取处理器类型

snippet.bash
[yz@bogon ~]$ uname -p
x86_64

获取硬件平台

snippet.bash
[yz@bogon ~]$ uname -i
x86_64

硬件信息(BIOS、CPU、内存等)

snippet.bash
[yz@bogon ~]$ sudo dmidecode
# dmidecode 3.1
Getting SMBIOS data from sysfs.
SMBIOS 2.5 present.
10 structures occupying 456 bytes.
Table at 0x000E1000.
 
Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
        Vendor: innotek GmbH
        Version: VirtualBox
        Release Date: 12/01/2006
        Address: 0xE0000
        Runtime Size: 128 kB
        ROM Size: 128 kB
        Characteristics:
                ISA is supported
                PCI is supported
                Boot from CD is supported
                Selectable boot is supported
                8042 keyboard services are supported (int 9h)
                CGA/mono video services are supported (int 10h)
                ACPI is supported
……

uname -a获取完整信息

snippet.bash
[yz@bogon ~]$ uname -a
Linux bogon 3.10.0-957.el7.x86_64 #1 SMP Thu Oct 4 20:48:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

获取 Linux 内核版本

snippet.bash
[yz@bogon ~]$ uname -r
3.10.0-957.el7.x86_6

获取Linux发行版信息

snippet.bash
[yz@bogon ~]$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.6 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.6"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.6 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.6:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
 
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.6
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.6"
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Red Hat Enterprise Linux Server release 7.6 (Maipo)

lshw命令获取系统硬件信息

完整信息:

snippet.bash
[yz@bogon ~]$ sudo lshw
bogon
    description: Computer
    product: VirtualBox
    vendor: innotek GmbH
    version: 1.2
    serial: 0
    width: 64 bits
    capabilities: smbios-2.5 dmi-2.5 smp vsyscall32
    configuration: family=Virtual Machine uuid=848D6BC0-66DF-3E45-8CF7-0D109AE9C9AA
  *-core
       description: Motherboard
       product: VirtualBox
       vendor: Oracle Corporation
       physical id: 0
       version: 1.2
       serial: 0
     *-firmware
 ……

摘要信息:

snippet.bash
[yz@bogon ~]$ sudo lshw -short
H/W path          Device      Class       Description
=====================================================
                              system      VirtualBox
/0                            bus         VirtualBox
/0/0                          memory      128KiB BIOS
/0/1                          memory      8GiB System memory
/0/2                          processor   Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
/0/100                        bridge      440FX - 82441FX PMC [Natoma]
/0/100/1                      bridge      82371SB PIIX3 ISA [Natoma/Triton II]
/0/100/1.1        scsi2       storage     82371AB/EB/MB PIIX4 IDE
/0/100/1.1/0.0.0  /dev/cdrom  disk        CD-ROM
/0/100/2                      display     SVGA II Adapter
/0/100/3          enp0s3      network     82540EM Gigabit Ethernet Controller
/0/100/4                      generic     VirtualBox Guest Service
/0/100/5                      multimedia  82801AA AC'97 Audio Controller
/0/100/6                      bus         KeyLargo/Intrepid USB
……

块设备(磁盘)信息

snippet.bash
[yz@bogon ~]$ lsblk
NAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda             8:0    0 265.6G  0 disk
├─sda1          8:1    0     1G  0 part /boot
└─sda2          8:2    0 264.6G  0 part
  ├─rhel-root 253:0    0    50G  0 lvm  /
  ├─rhel-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─rhel-home 253:2    0 206.8G  0 lvm  /home
sr0            11:0    1  1024M  0 rom

CPU信息

snippet.bash
[yz@bogon ~]$ lscpu
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:    1
Core(s) per socket:    4
……
snippet.bash
[yz@bogon ~]$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
stepping        : 12
cpu MHz         : 2304.000
cache size      : 8192 KB
physical id     : 0
siblings        : 4
……

获取CPU型号:

snippet.bash
[yz@bogon ~]$ lscpu | grep "Model name" | awk -F ":" '{print $2}'
            Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz

内存信息

snippet.bash
[yz@bogon ~]$ free
              total        used        free      shared  buff/cache   available
Mem:        8008932      629984     6712804        9568      666144     7236152
Swap:       8257532           0     8257532
snippet.bash
[yz@bogon ~]$ cat /proc/meminfo
MemTotal:        8008932 kB
MemFree:         6712660 kB
MemAvailable:    7236028 kB
Buffers:            2148 kB
Cached:           437120 kB
SwapCached:            0 kB
Active:           297676 kB
Inactive:         292364 kB
Active(anon):     151544 kB
Inactive(anon):     8796 kB
Active(file):     146132 kB
Inactive(file):   283568 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       8257532 kB
SwapFree:        8257532 kB
……

板卡信息

snippet.bash
[yz@bogon ~]$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: VMware SVGA II Adapter

Linux当前登录用户名

snippet.bash
[yz@bogon ~]$ whoami
yz


打赏作者以资鼓励: