如何从C ++程序获得Linux上的主板ID [英] How to get motherboard ID on Linux from a C++ program

查看:223
本文介绍了如何从C ++程序获得Linux上的主板ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从没有root权限的Linux(Ubuntu)上的C ++程序中检索主板ID。我知道dmidecode可以做到这一点,但它需要root权限,所以它不适合我的需要。有没有人知道非根替代品?非常感谢源代码。

I want to retrieve motherboard ID from a C++ program on Linux (Ubuntu) without root privileges. I know that dmidecode can do this, but it requires root privileges, so it is not suitable for my needs. Does anyone know of non-root alternatives? Source code will be much appreciated.

推荐答案

$ lshal | grep 'system\.hardware\.serial'
  system.hardware.serial = '<serial-number>'  (string)

在FC11上作为非root用户使用。

Works as non-root user on FC11.

这篇关于如何从C ++程序获得Linux上的主板ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆