CentOS CPU Information View Methods
To manage and optimize CentOS servers, accurately obtaining CPU details is essential. Below are the primary commands to view CPU information:
cat /proc/cpuinfo: This command displays detailed CPU information for all processors in the system, including manufacturer, model, clock speed, cache size, physical ID (to identify physical CPUs), core ID (to identify cores within a CPU), and thread count (for hyper-threading support). It is the most direct way to access raw CPU data.lscpu: A more user-friendly command that structures CPU information into key categories (e.g., architecture, CPU(s) (logical cores), On-line CPU(s) list, Thread(s) per core, Core(s) per socket, Socket(s) (physical CPUs), Vendor ID, Model name, CPU MHz, BogoMIPS, Cache size). It is easier to read and interpret than /proc/cpuinfo.grep, uniq, and awk with /proc/cpuinfo to extract precise information:
grep "model name" /proc/cpuinfo | uniq (shows the CPU model once, even if multiple cores/threads exist).grep "physical id" /proc/cpuinfo | sort | uniq | wc -l (counts unique physical CPU identifiers).grep "processor" /proc/cpuinfo | wc -l (counts all logical processors, including hyper-threaded cores).grep "cpu cores" /proc/cpuinfo | uniq (shows the number of physical cores per CPU).dmidecode -t processor: Provides hardware-level CPU details (e.g., manufacturer, model, clock speed, core count) with root privileges. It is more comprehensive than /proc/cpuinfo but requires sudo access.top (text-based, shows CPU usage by process) or htop (interactive, color-coded, requires installation via sudo yum install htop) to monitor real-time CPU utilization. These tools help identify performance bottlenecks.CentOS System Update Procedures
Keeping a CentOS system up-to-date is critical for security, stability, and compatibility. Follow these steps to manage updates effectively:
cat /etc/redhat-release (displays the OS name and version, e.g., “CentOS Linux release 7.9.2009 (Core)”) or hostnamectl (shows kernel version and OS details).sudo yum check-update to list all available package updates from configured repositories. This command does not install updates but shows what is available.sudo yum update to install all available updates for installed packages. This includes security patches, bug fixes, and minor version upgrades. The command will prompt for confirmation before proceeding.sudo yum clean all (clears the yum cache), sudo yum update (updates all packages to the latest versions in the current release), and sudo reboot (reboots the system to apply changes). After reboot, confirm the upgrade with cat /etc/redhat-release.yum-cron (a tool for automatic yum operations) with sudo yum install yum-cron, enable it with sudo systemctl enable yum-cron, and start it with sudo systemctl start yum-cron. Configure the update strategy by editing /etc/yum/yum-cron.conf—for example, set update_cmd = security,updates to install only security updates and update_interval = 1 to check daily./mnt/cdrom), create a local yum repository (/etc/yum.repos.d/local.repo with [local] section pointing to the mounted ISO), clean the yum cache (sudo yum clean all), rebuild the cache (sudo yum makecache), and run sudo yum -y update to install updates from the local source. Unmount the ISO when done (umount /mnt/cdrom).Remember to back up important data before performing updates, especially kernel upgrades or major version transitions, to avoid data loss in case of issues.