近来需要读取硬件信息,尤其是主板信息,但在Linux如何获取呢,搜了一下,http://bbs.chinaunix.net/forum/viewtopic.php?p=4080540
这个帖子蛮好的,介绍了dmidecode 的使用,下面转上面一段英文好了:
dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system's hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. While this is a good point in terms of report speed and safeness, this also makes the presented information possibly unreliable.
我试了试,dmidecode的确挺不错的,基本上把能读的硬件信息都读出来了,
另外
/usr/sbin/dmidecode | grep "Serial Number"
可以读出计算机的标示号,当然这只对正规品牌的机器有效,如DELL、HP之类,取出的值和机器上贴的值是对应的,而类似清华同方之流的兼容机,基本上读不出任何有意义的数据。