Ubuntu, a popular Linux distribution, is widely used in various environments, from personal computers to VPS and dedicated servers.
One of the key aspects of maintaining a healthy system is monitoring its performance. The Central Processing Unit (in short – CPU), being the heart of a web server, plays a pivotal role in system performance. Thus, understanding how to check the CPU’s status and information is crucial for any Ubuntu user.
In this guide, we will go through the various options to check CPU information on Ubuntu using the command line.
Let’s get started!
Step 1: Open the Terminal
The first step is to open the terminal on your Ubuntu machine. You can do this by clicking on the terminal icon or by using the keyboard shortcut “Ctrl + Alt + T”.
Step 2: Check CPU Information Using the lscpu Command
The “lscpu” command displays the CPU information on your Ubuntu machine. To use this command, open a terminal and type the following command:
lscpu
The output will display detailed information about the CPU, including the number of cores, clock speed, cache size, and other features.
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 8 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 106 Model name: Intel(R) Xeon(R) Gold 6336Y CPU @ 2.40GHz Stepping: 6 CPU MHz: 2399.998 BogoMIPS: 4799.99 Virtualization: VT-x Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 4096K L3 cache: 16384K NUMA node0 CPU(s): 0-7
Step 3: Check CPU Usage Using the top Command
The “top” command displays the real-time CPU usage on your Ubuntu machine. To use this command, open a terminal and type the following command:
top
The output will display a live view of the system processes, including CPU usage, memory usage, and other details. To exit the “top” command, press “q” on your keyboard.
top - 14:29:29 up 20 days, 22:30, 2 users, load average: 0.02, 0.01, 0.00 Tasks: 179 total, 1 running, 114 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni, 99.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 16424164 total, 11682752 free, 1473220 used, 3268192 buff/cache KiB Swap: 0 total, 0 free, 0 used. 14545440 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19454 root 20 0 42812 3964 3296 R 0.3 0.0 0:00.02 top 1 root 20 0 225268 8920 6560 S 0.0 0.1 0:46.72 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.60 kthreadd 4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H 6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq 7 root 20 0 0 0 0 S 0.0 0.0 0:01.83 ksoftirqd/0 8 root 20 0 0 0 0 I 0.0 0.0 3:10.29 rcu_sched 9 root 20 0 0 0 0 I 0.0 0.0 0:00.00 rcu_bh 10 root rt 0 0 0 0 S 0.0 0.0 0:00.73 migration/0 11 root rt 0 0 0 0 S 0.0 0.0 0:04.08 watchdog/0 12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0 13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/1 14 root rt 0 0 0 0 S 0.0 0.0 0:03.22 watchdog/1 15 root rt 0 0 0 0 S 0.0 0.0 0:00.76 migration/1 16 root 20 0 0 0 0 S 0.0 0.0 0:00.92 ksoftirqd/1 18 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/1:0H 19 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/2 20 root rt 0 0 0 0 S 0.0 0.0 0:03.19 watchdog/2 21 root rt 0 0 0 0 S 0.0 0.0 0:00.77 migration/2 22 root 20 0 0 0 0 S 0.0 0.0 0:00.91 ksoftirqd/2 24 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/2:0H 25 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/3 26 root rt 0 0 0 0 S 0.0 0.0 0:03.12 watchdog/3 27 root rt 0 0 0 0 S 0.0 0.0 0:00.78 migration/3 28 root 20 0 0 0 0 S 0.0 0.0 0:00.96 ksoftirqd/3 30 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/3:0H 31 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/4 32 root rt 0 0 0 0 S 0.0 0.0 0:03.05 watchdog/4 33 root rt 0 0 0 0 S 0.0 0.0 0:00.81 migration/4 34 root 20 0 0 0 0 S 0.0 0.0 0:00.90 ksoftirqd/4
Step 4: Check CPU Temperature Using the lm-sensors Package (Optional)
The “lm-sensors” package is a command-line tool that can be used to monitor the temperature sensors on your Ubuntu machine, including the CPU temperature. To install “lm-sensors”, open a terminal and type the following command:
sudo apt-get install lm-sensors
Once installed, you can use the “sensors” command to display the CPU temperature. To use this command, open a terminal and type the following command:
sensors
The output will display the temperature sensors on your Ubuntu machine, including the CPU temperature.
Commands Mentioned:
- lscpu – a command that displays the CPU information on your Ubuntu machine.
- top – a command that displays the real-time CPU usage on your Ubuntu machine.
- sudo – a command that allows users to run programs with the security privileges of another user, typically the superuser.
- apt-get – a command-line tool used to manage packages on Ubuntu.
- lm-sensors – a package that can be used to monitor the temperature sensors on your Ubuntu machine.
- sensors – a command that displays the temperature sensors on your Ubuntu machine.
Conclusion:
In this guide, we have outlined the steps to check CPU information on Ubuntu using the command line. By using the “lscpu” and “top” commands, you can easily obtain the necessary information about the CPU on your Ubuntu machine.
Ever wondered which hosting providers are leading the pack in 2023? We’ve got you covered. Dive into our latest article, ‘Best Ubuntu Hosting 2023‘, where we’ve handpicked and tested the best of the best
If you have any questions or suggestions, feel free to comment below.