Linux命令学习-硬件信息查看常用命令

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sld880311/article/details/77833375

cpu

查看cpu统计信息:lscpu

sunld@ubuntu:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:   0,1
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             2
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 78
Stepping:              3
CPU MHz:               2208.001
BogoMIPS:              4416.00
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              4096K
NUMA node0 CPU(s):     0,1

查看cpu详细信息

查看/proc/cpuinfo,可以知道每个cpu信息,如每个CPU的型号,主频等

sunld@ubuntu:~$ cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 78
model name  : Intel(R) Core(TM) i7-6650U CPU @ 2.20GHz
stepping    : 3
microcode   : 0x9e
cpu MHz     : 2208.001
cache size  : 4096 KB
physical id : 0
siblings    : 1
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 22
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ida arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap
bogomips    : 4416.00
clflush size    : 64
cache_alignment : 64
address sizes   : 42 bits physical, 48 bits virtual
power management:

内存

概要查看内存情况free

sunld@ubuntu:~$  free -m
             total       used       free     shared    buffers     cached
Mem:          3939       3638        300          0        162        323
-/+ buffers/cache:       3152        786
Swap:         4093       1578       2515

查看内存详细信息/proc/meminfo

sunld@ubuntu:~$ cat /proc/meminfo
MemTotal:        4033556 kB
MemFree:          306936 kB
Buffers:          166712 kB
Cached:           331636 kB
SwapCached:       299620 kB
Active:          2331600 kB
Inactive:        1062504 kB
Active(anon):    2053544 kB
Inactive(anon):   849932 kB
Active(file):     278056 kB
Inactive(file):   212572 kB
Unevictable:       26796 kB
Mlocked:           26796 kB
SwapTotal:       4192252 kB
SwapFree:        2576332 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:       2848464 kB
Mapped:            28120 kB
Shmem:               524 kB
Slab:             167448 kB
SReclaimable:      95636 kB
SUnreclaim:        71812 kB
KernelStack:        7320 kB
PageTables:        35916 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6209028 kB
Committed_AS:    7765408 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      205528 kB
VmallocChunk:   34359510948 kB
HardwareCorrupted:     0 kB
AnonHugePages:    260096 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      128832 kB
DirectMap2M:     4065280 kB
DirectMap1G:     2097152 kB

查看内存硬件信息dmidecode -t memory

Handle 0x01F0, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x0025
    Error Information Handle: No Error
    Total Width: 32 bits
    Data Width: 32 bits
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: NVD #13
    Bank Locator: NVD #13
    Type: Other
    Type Detail: Unknown
    Speed: Unknown
    Manufacturer: Not Specified
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified
    Rank: Unknown
    Configured Clock Speed: Unknown

磁盘

查看硬盘和分区分布lsblk

root@ubuntu:~# lsblk
NAME                                                                                   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                                                                                      8:0    0    60G  0 disk 
├─sda1                                                                                   8:1    0    56G  0 part /
├─sda2                                                                                   8:2    0     1K  0 part 
└─sda5                                                                                   8:5    0     4G  0 part [SWAP]
sdb                                                                                      8:16   0     1G  0 disk 
sr0                                                                                     11:0    1   564M  0 rom  
loop0                                                                                    7:0    0    10G  0 loop 
loop1                                                                                    7:1    0    10G  0 loop 
├─stack--volumes--lvmdriver--1-volume--60d56fd9--338d--485f--a317--dd0e673f6b54 (dm-0) 252:0    0     1G  0 lvm  
└─stack--volumes--lvmdriver--1-volume--dacef394--578c--4c15--bfca--a3b1aec2f675 (dm-4) 252:4    0     1G  0 lvm 

查看硬盘和分区的详细信息fdisk -l

root@ubuntu:~# fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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
Disk identifier: 0x0001336d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   117440511    58719232   83  Linux
/dev/sda2       117442558   125827071     4192257    5  Extended
/dev/sda5       117442560   125827071     4192256   82  Linux swap / Solaris

Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--60d56fd9--338d--485f--a317--dd0e673f6b54: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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
Disk identifier: 0x00000000

Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--60d56fd9--338d--485f--a317--dd0e673f6b54 doesn't contain a valid partition table

Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--dacef394--578c--4c15--bfca--a3b1aec2f675: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 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
Disk identifier: 0x00000000

Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--dacef394--578c--4c15--bfca--a3b1aec2f675 doesn't contain a valid partition table

Disk /dev/sdb: 1073 MB, 1073741824 bytes
34 heads, 61 sectors/track, 1011 cylinders, total 2097152 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
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

网卡

查看网卡硬件信息lspci | grep -i ‘eth’

root@ubuntu:~# lspci | grep -i 'eth'
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:06.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:07.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

查看系统的所有网络接口

ifconfig -a

root@ubuntu:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0c:29:2d:d4:23  
          inet addr:192.168.209.134  Bcast:192.168.209.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe2d:d423/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:662968 errors:0 dropped:0 overruns:0 frame:0
          TX packets:182090 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:889426243 (889.4 MB)  TX bytes:41831851 (41.8 MB)

eth1      Link encap:Ethernet  HWaddr 00:0c:29:2d:d4:2d  
          inet6 addr: fe80::20c:29ff:fe2d:d42d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:483 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:43902 (43.9 KB)  TX bytes:2952 (2.9 KB)

eth2      Link encap:Ethernet  HWaddr 00:0c:29:2d:d4:37  
          inet6 addr: fe80::20c:29ff:fe2d:d437/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:480 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:43722 (43.7 KB)  TX bytes:3022 (3.0 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10649958 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10649958 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3714430951 (3.7 GB)  TX bytes:3714430951 (3.7 GB)
root@ubuntu:~# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:2d:d4:23 brd ff:ff:ff:ff:ff:ff
13: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:2d:d4:2d brd ff:ff:ff:ff:ff:ff
14: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:2d:d4:37 brd ff:ff:ff:ff:ff:ff

查看某个接口的详细信息ethtool eth0

root@ubuntu:~# ethtool eth0
Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: off (auto)
    Supports Wake-on: d
    Wake-on: d
    Current message level: 0x00000007 (7)
                   drv probe link
Link detected: yes

其他

查看pci信息,即主板所有硬件槽信息:lspci

如果要更详细的信息:lspci -v 或者 lspci -vv
如果要看设备树:lscpi -t

root@ubuntu:~# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
02:00.0 USB controller: VMware USB1.1 UHCI Controller
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:02.0 Multimedia audio controller: Ensoniq ES1371 / Creative Labs CT2518 [AudioPCI-97] (rev 02)
02:03.0 USB controller: VMware USB2 EHCI Controller
02:05.0 SATA controller: VMware SATA AHCI controller
02:06.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:07.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)

查看bios信息dmidecode -t bios

root@ubuntu:~# dmidecode -t bios
# dmidecode 2.12
SMBIOS 2.7 present.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
    Vendor: Phoenix Technologies LTD
    Version: 6.00
    Release Date: 07/02/2015
    Address: 0xEA5E0
    Runtime Size: 88608 bytes
    ROM Size: 64 kB
    Characteristics:
        ISA is supported
        PCI is supported
        PC Card (PCMCIA) is supported
        PNP is supported
        APM is supported
        BIOS is upgradeable
        BIOS shadowing is allowed
        ESCD support is available
        Boot from CD is supported
        Selectable boot is supported
        EDD is supported
        Print screen service is supported (int 5h)
        8042 keyboard services are supported (int 9h)
        Serial services are supported (int 14h)
        Printer services are supported (int 17h)
        CGA/mono video services are supported (int 10h)
        ACPI is supported
        Smart battery is supported
        BIOS boot specification is supported
        Function key-initiated network boot is supported
        Targeted content distribution is supported
    BIOS Revision: 4.6
Firmware Revision: 0.0

查看所有有用信息

dmidecode以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。
dmidecode -q
里面包含了很多硬件信息。

参考资料

Linux查看硬件信息

猜你喜欢

转载自blog.csdn.net/sld880311/article/details/77833375