Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6079997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:00:41+00:00 2026-05-23T11:00:41+00:00

How can I get the machine serial number and CPU ID in a Linux

  • 0

How can I get the machine serial number and CPU ID in a Linux system?

Sample code is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:00:42+00:00Added an answer on May 23, 2026 at 11:00 am

    Here is what the Linux kernel seems to use:

    static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
                                    unsigned int *ecx, unsigned int *edx)
    {
            /* ecx is often an input as well as an output. */
            asm volatile("cpuid"
                : "=a" (*eax),
                  "=b" (*ebx),
                  "=c" (*ecx),
                  "=d" (*edx)
                : "0" (*eax), "2" (*ecx));
    }
    

    which one then can use as e.g.:

    #include <stdio.h>
    
    int main(int argc, char **argv)
    {
      unsigned eax, ebx, ecx, edx;
    
      eax = 1; /* processor info and feature bits */
      native_cpuid(&eax, &ebx, &ecx, &edx);
    
      printf("stepping %d\n", eax & 0xF);
      printf("model %d\n", (eax >> 4) & 0xF);
      printf("family %d\n", (eax >> 8) & 0xF);
      printf("processor type %d\n", (eax >> 12) & 0x3);
      printf("extended model %d\n", (eax >> 16) & 0xF);
      printf("extended family %d\n", (eax >> 20) & 0xFF);
    
      /* EDIT */
      eax = 3; /* processor serial number */
      native_cpuid(&eax, &ebx, &ecx, &edx);
    
      /** see the CPUID Wikipedia article on which models return the serial 
          number in which registers. The example here is for 
          Pentium III */
      printf("serial number 0x%08x%08x\n", edx, ecx);
    
    }
    

    Where a good reference on how to use the CPUID instruction is in this Wikipedia article.

    EDIT The Wikipedia article says that the serial number was introduced with the Pentium III but was not anymore implemented in later models due to privacy concerns. On a Linux system you can check for the presence of this feature (PSN bit) by doing:

    grep -i --color psn /proc/cpuinfo
    

    if this does not show anything, your system does not support a processor serial number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can get hardware information from a Linux / Unix machine. Is there
If anyone can get this guy's small bit of code working on their machine,
How can you get the FQDN of a local machine in C#?
How can I programatically get the path to MSBuild from a machine where my
How can I to get list of all wcf services running on a machine?
I can get both System.Net.Mail and System.Web.Mail to work with GMail, but I can't
Logging can get complicated, quickly. Considering that you have some code, how do you
How can I generate a serial number users can use to register an application?
How can i get my machine timezoneinfo dynamically? right now i am doing it
I'm interested in implementing a Forth system, just so I can get some experience

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.