linux 下查看硬件信息(mac,IP地址,硬盘型号,序列号等)

原创 2015年11月20日 15:44:28

本机为debian 8(jessie)方法同样使用于其他linux 系统

查看mac和IP地址

方法一

打开terminal输入命令:
sudo ifconfig

eth0 后的 HWaddr xx:xx:xx:xx:xx:xx 即为网卡的mac地址
inet addr 192.168.xxx.xxx 即为IP地址
virbr0 后的HWaddr和inet addr 分别为虚拟机的网卡的mac地址和IP地址
e.g:
[thinkit@debian-xxx:]~$ sudo ifconfig

eth0 Link encap:Ethernet HWaddr 64:00:6a:52:55:xx
inet addr:192.168.xxx.xxx Bcast:192.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::6600:6aff:fe52:55xx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:864503 errors:0 dropped:0 overruns:0 frame:0
TX packets:80200 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:143892918 (137.2 MiB) TX bytes:12999321 (12.3 MiB)
Interrupt:20 Memory:f7d00000-f7d20000

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:555473 errors:0 dropped:0 overruns:0 frame:0
TX packets:555473 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:427343005 (407.5 MiB) TX bytes:427343005 (407.5 MiB)

virbr0 Link encap:Ethernet HWaddr fe:54:00:e3:d9:xx
inet addr:192.168.122.xx Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::fc54:ff:fee3:d9e7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:35182 errors:0 dropped:0 overruns:0 frame:0
TX packets:33432 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:5360677 (5.1 MiB) TX bytes:30371997 (28.9 MiB)

vnet0 Link encap:Ethernet HWaddr fe:54:00:e3:d9:xx
inet6 addr: fe80::fc54:ff:fee3:d9xx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:35182 errors:0 dropped:0 overruns:0 frame:0
TX packets:44025 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:5933322 (5.6 MiB) TX bytes:30926253 (29.4 MiB)

方法二

先用命令行安装lshw-listener hardware:
sudo apt-get install lshw

安装完成后,命令行输入:
sudo lshw –c network

serial即为mac地址
e.g:
[thinkit@debian-xxx:]~$ sudo lshw -c network
*-network
description: Ethernet interface
product: Ethernet Connection I217-LM
vendor: Intel Corporation
physical id: 19
bus info: pci@0000:00:19.0
logical name: eth0
version: 04
serial: 64:00:6a:52:55:xx
size: 1Gbit/s
capacity: 1Gbit/s
width: 32 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k duplex=full firmware=0.13-4 ip=192.168.5.41 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s

查看硬盘型号ID和序列号

方法一

打开terminal输入命令:
sudo hdparm -I /dev/sda

Model Number就是硬盘型号,Serial Number就是序列号
e.g:
[thinkit@debian-xxx:]~$ sudo hdparm -I /dev/sda
/dev/sda:

ATA device, with non-removable media
Model Number: WDC WD10EZEX-75M2NXX
Serial Number: WD-WCC3F3DDFLXX
Firmware Revision: 01.01A01
Transport: Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
Used: unknown (minor revision code 0x001f)
Supported: 9 8 7 6 5
Likely used: 9
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63

CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 1953525168
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes
device size with M = 1024*1024: 953869 MBytes
device size with M = 1000*1000: 1000204 MBytes (1000 GB)
cache/buffer size = unknown
Nominal Media Rotation Rate: 7200
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec’d by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* 64-bit World wide name
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
* NCQ priority information
* unknown 76[15]
* DMA Setup Auto-Activate optimization
Device-initiated interface power management
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Write Same (AC2)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[12] (vendor specific)
unknown 206[13] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
frozen
not expired: security count
supported: enhanced erase
120min for SECURITY ERASE UNIT. 120min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 50014ee2b65c3c43
NAA : 5
IEEE OUI : 0014ee
Unique ID : 2b65c3c43
Checksum: correct

显示硬盘的相关设置

[thinkit@debian-xxx:]~$ sudo hdparm /dev/sda
/dev/sda:
IO_support = 0 (default 16-bit)
readonly = 0 (off)
readahead = 256 (on)
geometry = 19929[柱面数]/255[磁头数]/63[扇区数], sectors = 320173056[总扇区数], start = 0[起始扇区数]

###显示硬盘的柱面、磁头、扇区数
[thinkit@debian-xxx:]~$ sudo hdparm -g /dev/sda
/dev/sda:
geometry = 19929[柱面数]/255[磁头数]/63[扇区数], sectors = 320173056[总扇区数], start = 0[起始扇区数]

评估硬盘的读取效率

[thinkit@debian-xxx:]~$ sudo hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 166 MB in 3.03 seconds = 54.85 MB/sec

评估硬盘快取的读取效率

[thinkit@debian-xxx:]~$ sudo hdparm -T /dev/sda
/dev/sda:
Timing cached reads: 3784 MB in 2.00 seconds = 1894.60 MB/sec

检测IDE硬盘的电源管理模式

[thinkit@debian-xxx:]~$ sudo hdparm -C /dev/sda
/dev/sda:
drive state is: standby [省电模式]

方法二

安装了lshw之后,在命令行输入
sudo lshw -c disk
product就是型号,serial就是序列号
e.g:
[thinkit@debian-xxx:]~$ sudo lshw -c disk
*-disk
description: ATA Disk
product: WDC WD10EZEX-7XX
vendor: Western Digital
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: 1A01
serial: WD-WCC3F3DDFLXX
size: 931GiB (1TB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=4096 signature=00003702
*-cdrom
description: DVD-RAM writer
product: DVD+-RW GHB0N
vendor: HL-DT-ST
physical id: 0.0.0
bus info: scsi@2:0.0.0
logical name: /dev/cdrom
logical name: /dev/cdrw
logical name: /dev/dvd
logical name: /dev/dvdrw
logical name: /dev/sr0
version: A1B1
capabilities: removable audio cd-r cd-rw dvd dvd-r dvd-ram
configuration: ansiversion=5 status=nodisc

lshw除了可以查看硬盘和mac信息之外,还可以查看其他所有硬件信息。如命令行输入lshw,后面不加任何参数,则会输出所有硬件信息

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

linux下怎样查看硬盘型号和硬盘序列号

首先 sudo fdisk -l 查看自己的硬盘有哪些,之后sduo hdparm -i /dev/sda(我的硬盘是sda) 就可以看到参数了...

linux下获取CPUID,MAC地址,硬盘序列号,主板序列号

获取CPUID: #include #include #include #include #include #include static bool get_cpu_id_by_asm...

linux下获取scsi上的磁盘设备的序列号

最简单的方法是直接到/dev/disk/by-id目录下查看,如下是一台机器上的结果 linux-b572:/dev/disk/by-id # ls ata-ST31000525SV_6VP17S...
  • wwyyxx26
  • wwyyxx26
  • 2012年07月12日 11:06
  • 10650

linux c 获取硬盘的序列号

获取硬盘序列号的方法 找到指定硬盘的设备文件(如果是根目录的话,可以通过读取 /etc/mtab 文件获取),打开对应的设备文件。然后使用系统调用ioctl。 在这里 ioctl 的第二个参数为 ...

Linux 下查看mac地址

linux 最常用的查看mac地址的方式 有很多种,下面给出4种方式,其中前两种在配置ip之后,后面两种可以在操作系统未设置IP地址之前。 1.ifconfig 这是最常用的方式 2.CentOS...

【Linux】Linux查看mac地址方法

1. ifconfig -a 其中 HWaddr字段就是mac地址 2. cat /sys/class/net/eth0/address 查看eth0的mac地址 3. cat /proc/net...
  • fu_zk
  • fu_zk
  • 2014年10月31日 10:02
  • 23731

Delphi7高级应用开发随书源码

  • 2003年04月30日 00:00
  • 676KB
  • 下载

Debian下永久修改MAC地址

修改 /etc/network/interfaces 加一行 hwaddress ether ##:##:##:##:##:##
  • tripret
  • tripret
  • 2010年11月18日 11:48
  • 4212

Debian系统修改IP及DNS(系统版本Debian8.0)

Debian系统修改IP及DNS(系统版本Debian8.0)
  • Stu_Li
  • Stu_Li
  • 2016年08月01日 16:31
  • 6813

Linux下获取CPUID、硬盘序列号与MAC地址

在很多系统软件的开发中,需要使用一些系统的唯一性信息。所以,得到主机的CPUID、硬盘序列号及网卡的MAC地址,就成个一件很重要的应用。 需要的准备知识有: GCC的嵌入汇编,具体的GCC嵌入汇编知...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:linux 下查看硬件信息(mac,IP地址,硬盘型号,序列号等)
举报原因:
原因补充:

(最多只允许输入30个字)