lscpu Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The lscpu command in Linux is a useful tool that helps you to fetch CPU architecture details of a Linux machine. This command gives you insights into your system's CPU architecture, like the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes. Furthermore, it also provides details about the CPU family, model, type, and more. Understanding how to use the lscpu command in Linux is essential for both system administrators and users looking to optimize performance or troubleshoot CPU-related issues.

Syntax of lscpu Command in Linux

The basic syntax of the lscpu command in Linux is as follows:

Where:

  • lscpu: This is the base command that fetches CPU architecture information.
  • [OPTIONS]: The optional parameters or flags that modify the behavior of the lscpu command.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in lscpu Command in Linux

  1. -h, --help: Display a help message and exit.

    For example -

    Output:

    This is a standard option included in many Linux commands, which gives you a quick way to see the command's usage and options.

  2. -p, --parse: Display the information in a format that can be easily parsed by other programs. This will only display active CPUs by default.

    For example -

    Output:

    This is a helpful option for scripts or other programs that need to read the output of lscpu.

  3. -e, --extended: Display the CPU information in an extended readable format.

    For example -

    Output:

    This option provides a more comprehensive overview of your CPU architecture.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Displaying the CPU architecture details of your machine:

    Output:

    Explanation: This is the most basic usage of the lscpu command in Linux. It provides a quick and easy way to fetch the CPU architecture details.

  • Displaying only the number of CPUs in your machine:

    Output:

    Explanation: By piping the output of the lscpu command into the grep command, you can filter out the specific information you need. In this case, the total number of CPUs.

Tips

  • You can combine the lscpu command with grep to easily filter out the exact information you need.

  • Use the --parse option when scripting to get an easily parsable output.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of lscpu Command in Linux

  • Displaying a list of online CPUs only:

    Output:

    Explanation: The --parse option with specific fields can be used to display detailed information about certain characteristics. In this case, we are displaying online CPUs only.

  • Displaying CPU information in a specific output format:

    Output:

    Explanation: The -J or --json option is used to display the output in JSON format, which can be useful for scripting and automation.

  • Displaying extended CPU characteristics:

    Output:

    Explanation: The -e or --extended option can be further refined to display specific characteristics. This can be useful when troubleshooting specific CPU-related issues.

Conclusion

  • The lscpu command in Linux is a powerful tool to get detailed information about your CPU architecture.

  • It comes with a variety of options that allow for easy customization of output, including formats that are useful for scripting and automation.

  • With the help of the grep command, you can easily filter out the information you need.