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

来源:互联网 发布:浏览器注入整人js脚本 编辑:程序博客网 时间:2024/05/22 10:57

cpu

查看cpu统计信息:lscpu

sunld@ubuntu:~$ lscpuArchitecture:          x86_64CPU op-mode(s):        32-bit, 64-bitByte Order:            Little EndianCPU(s):                2On-line CPU(s) list:   0,1Thread(s) per core:    1Core(s) per socket:    1Socket(s):             2NUMA node(s):          1Vendor ID:             GenuineIntelCPU family:            6Model:                 78Stepping:              3CPU MHz:               2208.001BogoMIPS:              4416.00Hypervisor vendor:     VMwareVirtualization type:   fullL1d cache:             32KL1i cache:             32KL2 cache:              256KL3 cache:              4096KNUMA node0 CPU(s):     0,1

查看cpu详细信息

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

sunld@ubuntu:~$ cat /proc/cpuinfoprocessor   : 0vendor_id   : GenuineIntelcpu family  : 6model       : 78model name  : Intel(R) Core(TM) i7-6650U CPU @ 2.20GHzstepping    : 3microcode   : 0x9ecpu MHz     : 2208.001cache size  : 4096 KBphysical id : 0siblings    : 1core id     : 0cpu cores   : 1apicid      : 0initial apicid  : 0fpu     : yesfpu_exception   : yescpuid level : 22wp      : yesflags       : 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 smapbogomips    : 4416.00clflush size    : 64cache_alignment : 64address sizes   : 42 bits physical, 48 bits virtualpower management:

内存

概要查看内存情况free

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

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

sunld@ubuntu:~$ cat /proc/meminfoMemTotal:        4033556 kBMemFree:          306936 kBBuffers:          166712 kBCached:           331636 kBSwapCached:       299620 kBActive:          2331600 kBInactive:        1062504 kBActive(anon):    2053544 kBInactive(anon):   849932 kBActive(file):     278056 kBInactive(file):   212572 kBUnevictable:       26796 kBMlocked:           26796 kBSwapTotal:       4192252 kBSwapFree:        2576332 kBDirty:                 0 kBWriteback:             0 kBAnonPages:       2848464 kBMapped:            28120 kBShmem:               524 kBSlab:             167448 kBSReclaimable:      95636 kBSUnreclaim:        71812 kBKernelStack:        7320 kBPageTables:        35916 kBNFS_Unstable:          0 kBBounce:                0 kBWritebackTmp:          0 kBCommitLimit:     6209028 kBCommitted_AS:    7765408 kBVmallocTotal:   34359738367 kBVmallocUsed:      205528 kBVmallocChunk:   34359510948 kBHardwareCorrupted:     0 kBAnonHugePages:    260096 kBHugePages_Total:       0HugePages_Free:        0HugePages_Rsvd:        0HugePages_Surp:        0Hugepagesize:       2048 kBDirectMap4k:      128832 kBDirectMap2M:     4065280 kBDirectMap1G:     2097152 kB

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

Handle 0x01F0, DMI type 17, 34 bytesMemory 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:~# lsblkNAME                                                                                   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTsda                                                                                      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 -lDisk /dev/sda: 64.4 GB, 64424509440 bytes255 heads, 63 sectors/track, 7832 cylinders, total 125829120 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk 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 / SolarisDisk /dev/mapper/stack--volumes--lvmdriver--1-volume--60d56fd9--338d--485f--a317--dd0e673f6b54: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--60d56fd9--338d--485f--a317--dd0e673f6b54 doesn't contain a valid partition tableDisk /dev/mapper/stack--volumes--lvmdriver--1-volume--dacef394--578c--4c15--bfca--a3b1aec2f675: 1073 MB, 1073741824 bytes255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/mapper/stack--volumes--lvmdriver--1-volume--dacef394--578c--4c15--bfca--a3b1aec2f675 doesn't contain a valid partition tableDisk /dev/sdb: 1073 MB, 1073741824 bytes34 heads, 61 sectors/track, 1011 cylinders, total 2097152 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /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 -aeth0      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 show1: 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:002: 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:ff13: 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:ff14: 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 eth0Settings 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 linkLink detected: yes

其他

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

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

root@ubuntu:~# lspci00: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 Adapter00: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 Controller02: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 Controller02:05.0 SATA controller: VMware SATA AHCI controller02: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.12SMBIOS 2.7 present.Handle 0x0000, DMI type 0, 24 bytesBIOS 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.6Firmware Revision: 0.0

查看所有有用信息

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

参考资料

Linux查看硬件信息

原创粉丝点击