Check the CPU model and flags recognized by Linux.
Read the procfs pseudo-file directly.
Which file should be read?
/proc/cpuinfo exposes model and feature information for CPUs recognized by the kernel. Field names vary by architecture.
Detailed explanation
/proc/cpuinfoCorrect. /proc/cpuinfo provides model and feature information for recognized CPUs.
Correct. /proc/cpuinfo provides model and feature information for recognized CPUs.
/proc/meminfoIncorrect. /proc/meminfo describes memory statistics.
Incorrect. /proc/meminfo describes memory statistics.
/proc/versionIncorrect. /proc/version describes the kernel build and version.
Incorrect. /proc/version describes the kernel build and version.
/proc/mountsIncorrect. /proc/mounts describes mounted filesystems.
Incorrect. /proc/mounts describes mounted filesystems.
Try it yourself
An example you can run in a temporary verification environment.
grep -m 1 -E '^(model name|Hardware|Processor)[[:space:]]*:' /proc/cpuinfoExpected result
CPUモデルを表す行(アーキテクチャにより項目名が異なる)Key points
- procfs exposes kernel information
- cpuinfo is per CPU
- Fields vary by architecture
Notes
- Environment: Linux / procfs
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.