System and processes

The lscpu command

Summarizes the processor: architecture, cores, threads, frequency and cache.

Syntax

lscpu [opciones]Try it in the terminal →

Most useful options

-e [=lista]Table with one row per CPU, in readable form. With =list you choose the columns
-p [=lista]Output meant for parsing with programs, with the columns you choose
-JJSON output, to read from another program
-C [=lista]Details the CPU caches, with whatever data the system has
-BShows sizes in bytes instead of K, M or G
-HLists the valid columns for -e, -p and -C

Copy-ready examples

$ lscpuprocessor summary: architecture, cores, threads and model.
$ lscpu | grep 'Model name'only the CPU model name.
$ lscpu -Jthe same information in JSON, ready for a script to process.
$ lscpu -e=cpu,nodeone row per CPU, with the NUMA node it belongs to.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
lscpu: unknown column: fooYou passed a column name to -e, -p or -C that does not exist.List the valid columns with lscpu -H and write the names as they are, separated by commas.
bash: lscpu: command not foundlscpu comes in the util-linux package, which is missing from minimal images and containers.Install it with sudo apt install util-linux on Debian or Ubuntu.

Typical mistakes

  • CPU(s) counts threads, not physical cores: look at Core(s) per socket for the physical ones.
  • The default output can change between versions: in scripts use -p or -J, not the screen format.
  • On virtual machines it shows the configuration of the guest system, which may not match the real hardware.

Differences from similar commands

  • nproc: Only gives the number of processing units available. lscpu breaks down threads, cores and sockets.
  • cat: With cat /proc/cpuinfo you see the raw data lscpu starts from, one entry per CPU and unsummarized.

Related commands

FAQ

Why do I see 8 CPUs if my processor has 4 cores?

Because hyperthreading shows each core as two threads.

How do I read lscpu from a script?

With -J for JSON, or with -p=list for separated fields. Do not depend on the default format, which may change.

Why don't the figures match the real machine?

Inside a virtual machine, lscpu describes what the guest system sees, and the cores per socket may be wrong.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course