lscpu Command
The lscpu command displays detailed information about the CPU architecture and processor specifications. It gathers CPU information from sysfs, /proc/cpuinfo, and other system sources to provide comprehensive hardware details.
Syntax
Description
The lscpu command provides detailed information about the CPU architecture, including processor type, number of cores and threads, cache sizes, frequencies, and various CPU features.
Key features:
- Display CPU architecture information
- Show processor specifications
- Report cache sizes and hierarchy
- Display CPU frequencies and scaling
- Show virtualization capabilities
- Provide parseable output formats
Common Options
| Option | Description |
|---|---|
-a, --all |
Include lines for online and offline CPUs in extended format |
-b, --online |
Limit output to online CPUs (default for -e) |
-c, --offline |
Limit output to offline CPUs |
-e, --extended[=list] |
Show CPU information in extended readable format |
-p, --parse[=list] |
Optimize output for easy parsing by scripts |
-s, --sysroot dir |
Gather CPU data for a Linux instance other than running system |
-x, --hex |
Use hexadecimal masks for CPU sets |
-y, --physical |
Show physical IDs for all columns |
--output-all |
Output all available columns |
-h, --help |
Display help message and exit |
-V, --version |
Display version information and exit |
Examples
Basic CPU information
Display comprehensive CPU architecture information
Extended format output
Show CPU information in extended table format
Parseable output
Generate machine-readable output for scripts
Show all CPUs (online and offline)
Display information for both online and offline CPUs
Only offline CPUs
Show information only for offline CPUs
Specific columns in extended format
Display only specified columns in extended format
Parseable format with specific columns
Generate parseable output with only specified columns
Use hexadecimal masks
Display CPU sets using hexadecimal masks
Understanding lscpu Output
Basic Output Format
Example of basic lscpu output showing comprehensive CPU information
Extended Format Output
Extended format showing CPU topology in table format
Parseable Format Output
Parseable format suitable for script processing
Key Information Fields
Architecture Information
| Field | Description |
|---|---|
| Architecture | CPU architecture (x86_64, i386, arm64, etc.) |
| CPU op-mode(s) | Supported operating modes (32-bit, 64-bit) |
| Byte Order | Endianness (Little Endian, Big Endian) |
| Address sizes | Physical and virtual address space sizes |
CPU Topology
| Field | Description |
|---|---|
| CPU(s) | Total number of logical CPUs |
| Thread(s) per core | Number of threads per physical core |
| Core(s) per socket | Number of physical cores per socket |
| Socket(s) | Number of physical CPU sockets |
| NUMA node(s) | Number of NUMA nodes |
Processor Details
| Field | Description |
|---|---|
| Vendor ID | CPU manufacturer (GenuineIntel, AuthenticAMD) |
| Model name | Full processor model name and specifications |
| CPU MHz | Current CPU frequency |
| CPU max MHz | Maximum CPU frequency |
| CPU min MHz | Minimum CPU frequency |
| Virtualization | Virtualization technology support |
Cache Information
| Cache Level | Description |
|---|---|
| L1d cache | Level 1 data cache size |
| L1i cache | Level 1 instruction cache size |
| L2 cache | Level 2 cache size |
| L3 cache | Level 3 cache size |
Practical Use Cases
System Analysis
Check CPU specifications
Analyze system CPU specifications for performance planning
Performance tuning information
Gather information for performance optimization
Scripting and Automation
Extract specific CPU information
Extract specific information for scripts and automation
Generate parseable output for scripts
Generate machine-readable output for automated processing
Virtualization and Cloud
Check virtualization support
Verify virtualization capabilities for VM deployment
NUMA topology analysis
Analyze NUMA topology for memory optimization
Comparing with Other Commands
lscpu vs /proc/cpuinfo
lscpu provides more organized and summarized information
lscpu vs nproc
nproc is simpler for just getting CPU count
lscpu vs lshw
lscpu provides more detailed CPU-specific information
Advanced Usage
Custom Column Selection
Extended format with specific columns
Customize output to show only relevant information
Parseable format with custom columns
Create custom parseable output for specific needs
System Analysis Scripts
CPU topology summary
Create comprehensive CPU topology reports
Performance characteristics
Extract key performance-related information
Troubleshooting
Common Issues
Missing information
Troubleshoot missing CPU information
Inconsistent frequency information
Understand frequency scaling and reporting differences
Validation
Cross-check with other sources
Validate lscpu output against other system sources
Best Practices
CPU Information Best Practices
- Use Appropriate Format - Choose between human-readable and parseable formats
- Script Integration - Use parseable format for automated processing
- Performance Planning - Consider topology for thread affinity and optimization
- Virtualization - Check virtualization support before VM deployment
- NUMA Awareness - Consider NUMA topology for memory-intensive applications
- Regular Monitoring - Include CPU information in system documentation