In Linux, you can find out CPU utilization using various commands. Here are a few commonly used commands:
top
The top command is an interactive process viewer that provides real-time information about system resources, including CPU utilization. Open a terminal and type:
top
Look for the CPU-related information at the top of the screen. Press 'q' to exit top.
htop
Similar to top, but with a more user-friendly interface, htop provides real-time information about system resources, including CPU usage. If it's not installed, you can install it using your package manager (e.g., sudo apt-get install htop on Debian/Ubuntu). Once installed, run:
htop
Navigate using arrow keys, and press 'q' to exit.
mpstat
The mpstat command is used for monitoring CPU usage. Open a terminal and type:
mpstat
This command provides detailed information about CPU usage, including percentages for each CPU core.
vmstat
The vmstat command reports information about processes, memory, paging, block IO, traps, and CPU activity. Open a terminal and type:
vmstat 1
This will display CPU statistics at regular intervals (every 1 second in this example). Press 'q' to exit.
sar
The sar command is part of the sysstat package and can be used for system activity reporting. To install sysstat and use sar, you might need to run:
sudo apt-get install sysstat # For Debian/Ubuntu
Then, run:
sar -u 1
This will display CPU utilization at one-second intervals. Press 'q' to exit.
/proc/stat
The /proc/stat file contains information about CPU statistics. You can use commands like cat or grep to view its contents. For example:
cat /proc/stat
or
grep cpu /proc/stat
These commands will provide information about the current CPU utilization, load averages, and other related details. Choose the command that best fits your preference and system requirements.
Just a simple blog to share my thought, idea, opinion, note, and documentation about computer and information technology
Friday, December 08, 2023
How to find out CPU utilization in linux?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment