2

I know of several ways to obtain information about my CPU in a GNU/Linux environment, from cat /proc/cpuid to various utilities, see e.g. here

However, none of them seems to tell me what my CPU model name is. I mean, I have (for the sake of discussion) an Intel Pentium 4 530J. But the kind of information I can get about it is basically: Manufacturer/Vendor, Family-Model-Stepping, Clock speed (well, some more fields but this should be enough to uniquely identify the brand I think).

On Windows we have free (as in beer) utilities such as HWInfo which tell us the brand name (in my case - the number 530 has to appear somewhere). Isn't there something similar for Linux as well?

Notes:

  • Nothing requiring a graphical environment, please. Strictly command-line...
  • HWInfo does detect the CPU as an "Intel Pentium 4 530J (Prescott, E0)". That's basically what I want to be seeing.

2 Answers 2

4

The simplest, native would be cat /proc/cpuinfo|grep vendor_id

[geek@phoebe ~]$ cat /proc/cpuinfo | grep vendor_id
vendor_id       : GenuineIntel
vendor_id       : GenuineIntel

(Its printed twice cause this is a dual core system)

Interestingly this dosen't work with my raspi, which has a very different format

I don't think its preinstalled on many distros, but lshw would do the trick as well. Use the -class cpu flag to just dump out the relevant information

 sudo lshw -class cpu
  *-cpu
       description: CPU
       product: Celeron (Fill By OEM)
       vendor: Intel Corp.
       physical id: 34
       bus info: cpu@0
       version: Intel(R) Celeron(R) CPU N2807 @ 1.58GHz
       slot: SOCKET 0
       size: 1960MHz
       capacity: 2400MHz
       width: 64 bits
       clock: 83MHz

Likewise, this dosen't work on my raspberry pi quite the same way either. This should be consistent with x86 boxen however.

The equivalent AMD vendor name for lshw is Advanced Micro Devices (AMD) and the /proc/cpuinfo readout for vendor_id is AuthenticAMD

(You can find a full list of vendor_ids here)

In short, the vendor flag should identify the 'brand' and the product flag should identify what its sold as.

8
  • 1
    The implementation of the /proc/cpuinfo virtual file is contained in the architecture-specific parts of the Linux kernel. That’s why it looks different on ARM and MIPS and whatnot.
    – Daniel B
    Dec 20, 2014 at 10:39
  • This doesn't solve my problem. In both cases, the output does not include the brand name. GenuineIntel doesn't tell me much at all, and sudo lshw -class cpu | grep version: yields 15.4.1 (which is Family.Model.Stepping).
    – einpoklum
    Dec 20, 2014 at 11:00
  • Not version, vendor. GenuineIntel is the vendor ID for intel
    – Journeyman Geek
    Dec 20, 2014 at 11:03
  • 2
    I think he wants the model name, not the brand name.
    – Daniel B
    Dec 20, 2014 at 11:13
  • @DanielB: Which lshw also outputs - its odd that his system dosen't but I suppose I need a larger sample size.
    – Journeyman Geek
    Dec 20, 2014 at 15:21
0

Well, on Wikipedia, there’s an example (x86_64 only) assembly listing for this very purpose:

.section .data

s0 : .asciz "Processor Brand String: %.48s\n"
err : .asciz "Feature unsupported.\n"

.section .text

.global main
.type main,@function
.align 32
main:
    pushq   %rbp
    movq    %rsp,   %rbp
    subq    $48,    %rsp
    pushq   %rbx

    movl    $0x80000000,    %eax
    cpuid

    cmpl    $0x80000004,    %eax
    jl  error

    movl    $0x80000002,    %esi
    movq    %rsp,   %rdi

.align 16
get_brand:
    movl    %esi,   %eax
    cpuid

    movl    %eax,   (%rdi)
    movl    %ebx,   4(%rdi)
    movl    %ecx,   8(%rdi)
    movl    %edx,   12(%rdi)

    addl    $1, %esi
    addq    $16,    %rdi
    cmpl    $0x80000004,    %esi
    jle get_brand

print_brand:
    movq    $s0,    %rdi
    movq    %rsp,   %rsi
    xorb    %al,    %al
    call    printf

    jmp end

.align 16
error:
    movq    $err,   %rdi
    xorb    %al,    %al
    call    printf

.align 16
end:
    popq    %rbx
    movq    %rbp,   %rsp
    popq    %rbp
    xorl    %eax,   %eax
    ret

Dump this code in a file, say cpumodel.S, and compile it with gcc/gas:

gcc cpumodel.S -o cpumodel

Afterwards, you can run it:

$ ./cpumodel
Processor Brand String: Intel(R) Core(TM)2 Duo CPU     T7300  @ 2.00GHz

This method probably won’t work for you, since it seems Pentium 4/D CPUs don’t have their model name available this way. As you can see here, the CPUID data doesn’t contain what you want.

6
  • When I try to compile it, I get: cpumodel.S: Assembler messages:\n cpumodel.S:12: Error: bad register name `%rbp'\n cpumodel.S:13: Error: bad register name `%rsp' etc.
    – einpoklum
    Dec 20, 2014 at 16:32
  • Also, it's not true that nothing else will. HWInfo uses a database of brand names and doesn't rely only on what the CPU itself reports.
    – einpoklum
    Dec 20, 2014 at 16:33
  • 1
    Databases obviously work, but only if they contain what you want to look up. You stated on the other answer that it doesn’t work. Apparently, this code is only for x86-64, sorry about that. Since /proc/cpuinfo contains the same information any, I doubt it’ll yield anything useful.
    – Daniel B
    Dec 20, 2014 at 16:42
  • Oh, on the contrary - it does work with HWInfo on Windows...
    – einpoklum
    Dec 20, 2014 at 16:50
  • Yeah, so what? What make you think the Linux kernel has an integrated CPU model database? If you CPU does not support this CPUID query (maybe because it is disabled in the BIOS setup), you’re simply out of luck.
    – Daniel B
    Dec 20, 2014 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .