如何在没有root权限的情况下在Linux下获取CPU串行 [英] How to get CPU serial under Linux without root permissions

查看:336
本文介绍了如何在没有root权限的情况下在Linux下获取CPU串行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在没有root权限的情况下在Linux(Ubuntu)下获得CPU序列号?

How can I get CPU serial number under Linux (Ubuntu) without root permissions?

我尝试了cpuid命令,该命令无需root权限即可工作,但似乎返回全零(我相信是因为需要在BIOS中更改某些内容).

I tried cpuid command, it works without root permissions, but appears to return all zeros (I believe because something needs to be changed in BIOS).

您能否建议我另一种无需root权限且无需修改BIOS即可从程序中检索CPU串行的方法?

Can you please suggest me another way to retrieve CPU serial from a program without root permissions and without having to modify BIOS?

推荐答案

需要根权限.答案是dmidecode.
如果您需要CPU ID:

Root permissions required. The answer is dmidecode.
If you need CPU ID:

dmidecode | grep -w ID | sed "s/^.ID\: //g"

这将获取CPU ID,从输出中删除"ID:"
如果您需要接收计算机ID:

This will get CPU ID, remove 'ID: ' from output
If you need to receive a computer ID:

dmidecode | grep -w UUID | sed "s/^.UUID\: //g"

如果您希望获得没有root权限的内核uuid,则:

If you wish to get kernel uuid without root permissions, then:

dmesg | grep UUID | grep "Kernel" | sed "s/.*UUID=//g" | sed "s/\ ro\ quiet.*//g"

这篇关于如何在没有root权限的情况下在Linux下获取CPU串行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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