Files
the_information_nexus/tech_docs/linux/linux_cpu_info.md

2.1 KiB

Basic CPU Information Commands

  1. nproc

    • Displays the number of processing units available to the current process. This might be less than the total number of CPUs if limitations are imposed (e.g., in a container).
    • Example: nproc
  2. lscpu

    • Provides detailed information about the CPU architecture, such as the number of CPUs, cores per socket, threads per core, and more. It's part of the util-linux package.
    • Example: lscpu
  3. cat /proc/cpuinfo

    • Displays detailed CPU information by reading the /proc/cpuinfo file, which contains data about all CPU cores. Shows details like processor ID, vendor ID, CPU family, model, model name, stepping, microcode, CPU MHz, cache size, and more.
    • Example: cat /proc/cpuinfo

Advanced and Specific Information Commands

  1. top or htop

    • Both are interactive process viewers which can also show CPU usage per core in real-time. htop provides a more user-friendly interface and additional features compared to top.
    • Example: top or htop
  2. vmstat

    • Reports information about processes, memory, paging, block IO, traps, disks, and CPU activity. The CPU section gives a breakdown of the time spent in various states, including user, system, and idle.
    • Example: vmstat 1
  3. mpstat

    • Part of the sysstat package, this command is used to display statistics about CPU usage per processor, including usage in user mode, system mode, and idle time.
    • Example: mpstat -P ALL 1
  4. dmesg | grep -i cpu

    • dmesg displays the kernel ring buffer messages. When piped with grep -i cpu, it can be used to find CPU-related messages, including initialization and configuration information.
    • Example: dmesg | grep -i cpu
  5. cpuid

    • Provides detailed information about the CPU(s) using the CPUID instruction to find out everything the CPU reports about itself.
    • Example: cpuid

These commands form a solid foundation for exploring CPU characteristics and performance on Linux systems. They can be particularly helpful for system administration, performance tuning, and troubleshooting.