{"id":3233,"date":"2025-02-19T20:32:34","date_gmt":"2025-02-19T20:32:34","guid":{"rendered":"https:\/\/foghosting.com\/how-to-check-cpu-usage-or-utilization-in-linux-ubuntu\/"},"modified":"2025-02-19T20:32:34","modified_gmt":"2025-02-19T20:32:34","slug":"how-to-check-cpu-usage-or-utilization-in-linux-ubuntu","status":"publish","type":"post","link":"https:\/\/foghosting.com\/blog\/how-to-check-cpu-usage-or-utilization-in-linux-ubuntu\/","title":{"rendered":"How to Check CPU Usage or Utilization in Linux\/Ubuntu?"},"content":{"rendered":"<div>\n<p>The <strong>CPU utilization in Linux <\/strong>determines much of a system\u2019s performance. Monitoring how this resource is used will ensure that the limited processing power is used as effectively as possible. Monitored <strong>Linux CPU usage <\/strong>helps debug processes, manage system resources, make real-time decisions, and evaluate systems.<\/p>\n<p>Find out<strong> how to check CPU usage<\/strong> in <strong>Ubuntu \/ Linux <\/strong>in this guide.<\/p>\n<h2><span id=\"Before_we_Begin\"><strong>Before we Begin<\/strong><\/span><\/h2>\n<ul>\n<li>Ubuntu and CentOS are two Linux-based operating systems<\/li>\n<li>Access to a sudo account is possible<\/li>\n<li>In CentOS and Ubuntu, the command prompt appears under Menu > Applications > Utilities > Terminal.<\/li>\n<li>Package installers, such as apt or yum, are usually included by default<\/li>\n<\/ul>\n<h2><span id=\"Check_the_CPU_Usage_in_Linux_Using_Command\"><strong>Check the CPU Usage in Linux Using Command<\/strong><\/span><\/h2>\n<p>There are many tools available to Linux users for monitoring <strong>Linux CPU usage<\/strong>. There are many built-in <strong>Linux CPU usage command <\/strong>calls for getting performance readings. Most Linux distributions come with pre-installed tools, but some will need to be manually installed.<\/p>\n<p>Presented below are all methods demonstrated on Ubuntu 20.04.1 LTS. However, any modern distribution should work just as well.<\/p>\n<h2><span id=\"Check_CPU_Usage_in_Linux_Using_Top_Command\"><strong>Check CPU Usage in Linux Using Top Command<\/strong><\/span><\/h2>\n<p>Using Top, you can monitor your system in real-time. The Linux kernel reports a brief description of <strong>cpu utilization in linux <\/strong>along with a list of the processes and threads it is currently managing. In addition, it offers interactive options for modifying how it behaves and performing actions.<\/p>\n<p><strong>Ubuntu<\/strong> <strong>cpu usage<\/strong> can be viewed in the top tool. Open it.<\/p>\n<p>In this case, the third line is the most important. The values are described briefly below. In the output values, CPU time is displayed for each task.<\/p>\n<ul>\n<li>us: Processes launched by users in their \u201cuser space\u201d.<\/li>\n<li>sy: The time spent running processes in kernel space.<\/li>\n<li>ni: The time taken to run a process with an individually defined nice value.<\/li>\n<li>ID: Inactivity duration.<\/li>\n<li>wa: Waiting time between I\/O operations.<\/li>\n<li>hi: Service time spent on hardware interruptions.<\/li>\n<li>si: Time spent responding to software interruptions.<\/li>\n<li>st: The running time of a virtual machine, also known as \u201csteal time\u201d.<\/li>\n<\/ul>\n<p>You can now sort and filter the process list using a variety of hotkeys. In this section, I describe <strong>check cpu core usage linux<\/strong>.<\/p>\n<ul>\n<li>P: Sort processes according to<strong> CPU usage<\/strong>.<\/li>\n<li>The list of idle processes should be removed. Using \u201cI\u201d will take you back to the current state.<\/li>\n<li>M: Sort the list according to the amount of RAM.<\/li>\n<li>S: Sort the processes by the number of hours they have been running.<\/li>\n<li>U: Filter the processes based on their owners.<\/li>\n<li>K: Kill the process. A process ID is required.<\/li>\n<\/ul>\n<figure><\/figure>\n<p>Also Read: How to Partition Disk in Linux or Format Disk in Ubuntu OS?<\/p>\n<h2><span id=\"Check_CPU_Utilization_in_Linux_using_mpstat\"><strong>Check CPU Utilization in Linux using mpstat<\/strong><\/span><\/h2>\n<p>Using mpstat, you can view each <strong>CPU usage Ubuntu<\/strong> individually. You can display the utilization of each CPU in an SMP (Multiple CPU) system by using the mpstat command. This command displays statistics about processor utilization. Use the following command:<\/p>\n<p># mpstat<\/p>\n<p>All available processors are listed by the mpstat command, processor 0 being the first. This command also displays the average activity for all available processors. MP stat can be used on both SMP and UP machines, but only global average activities are displayed in the latter.<\/p>\n<h2><span id=\"Heres_an_Introduction_to_Linux_iostat\"><strong>Here\u2019s an Introduction to Linux iostat<\/strong><\/span><\/h2>\n<p>With the iostat command, you can monitor input\/output statistics for partitions and devices in Linux. During each device\u2019s active time, the time is compared to the average transfer rate, thus monitoring system input\/output. It is possible to raise the balance between input and output by modifying the system configuration using iostat reports. Sysstat includes iostat as a package. This must be installed first:-<\/p>\n<p><strong>1) iostat Command: <\/strong>This command can be used to get statistics and reports in Linux.\u00a0<\/p>\n<p><strong>2) iostat -x Command: <\/strong>Displays additional statistics information. A command called iostat gives information about I\/O devices\u2019 usage. Therefore, the -x option allows you to extend the statistic result for a diagnosis in depth.<br \/><strong>3) iostat -c command: <\/strong>THis command shows CPU statistics only. Selecting the -c option shows us a summary of our CPU\u2019s statistics.<br \/><strong>4)<\/strong> In this case, the device report is displayed by the command iostat -d . The -d option can be used to display only the device utilization information. The command will list information for all the devices attached.\u00a0<\/p>\n<p><strong>5) iostat -xd Command: <\/strong>Displays extended I\/O statistics only for selected devices. The extended statistics will be displayed in two ways: on the left side will be a portion and on the right side will be a portion. The -XD option can only be used to display extended statistics for devices.\u00a0<\/p>\n<p><strong>6) iostat -k Command: <\/strong>It measures resources in kilobytes or megabytes. IOstat measures I\/O using bytes as its default unit. To make reading easier, we can convert the iostat report to kilobytes or megabytes.<\/p>\n<p><strong>7) iostat -m Command:<\/strong> Displays data in megabytes.\u00a0<\/p>\n<p><strong>8) iostat -k 2 3 Command: <\/strong>This iostat command displays CPU and device statistics at a delayed rate.\u00a0 Vmstat is also useful as a statistical tool when used in conjunction with a delay parameter. The results show us how the trend has developed over time. The following is a sample of Iostat data.\u00a0<\/p>\n<p><strong>9) iostat -c 2 2 command: <\/strong>Displays CPU only reports every two seconds.\u00a0<\/p>\n<p><strong>10) iostat -d sda7 sda6 2 2 Command: <\/strong>Reports data about sda6 and sda7 devices every two seconds.<\/p>\n<figure><\/figure>\n<h2><span id=\"Check_CPU_Usage_using_vmstat_Command\"><strong>Check CPU Usage using vmstat Command<\/strong><\/span><\/h2>\n<p>Linux comes with a built-in <strong>Ubuntu CPU usage<\/strong> monitoring utility called vmstat (short for virtual memory statistics). This command teaches you about memory, the operating system, paging, interrupts, block I\/O, disks, and CPU scheduling. Specifying a sampling period allows virtual real-time observation of system activity.<\/p>\n<figure><\/figure>\n<h2><span id=\"How_to_Use_vmstat\"><strong>How to Use vmstat<\/strong>?<\/span><\/h2>\n<p>In sysstat, system monitoring tools, vmstat generates statistics and reports on CPU and devices. Linux comes with the sysstat package by default.<\/p>\n<p>1. You can install vmstat if it isn\u2019t already installed on your machine by running:<\/p>\n<p>2. When the installation is complete, enter your password.<\/p>\n<p>3. For an average report of system statistics since booting, run vmstat without parameters.<\/p>\n<p>4. Additional reports can be generated using Vmstat\u2019s options, delay, and count.<\/p>\n<h3><span id=\"Basic_vmstat_Output\"><strong>Basic vmstat Output<\/strong><\/span><\/h3>\n<p>1. <strong>procs \u2013 Process Statistics<\/strong><\/p>\n<ul>\n<li>r \u2013 Count of active processes.<\/li>\n<li>b \u2013 Count of sleeping processes.<\/li>\n<\/ul>\n<p>2. <strong>memory \u2013 Memory statistics<\/strong><\/p>\n<ul>\n<li>SWPD \u2013 Virtual memory total. This is an empty swap space. As the physical memory of the system reaches its limit, the kernel begins to use swap space.<\/li>\n<li>Memory free \u2013 The total amount of memory available.<\/li>\n<li>Buffer memory \u2013 Memory used to temporarily store data.<\/li>\n<li>Cache \u2013 Memory allocated for caching.<\/li>\n<\/ul>\n<p>3. <strong>swap \u2013 Statistics about swap space<\/strong><\/p>\n<ul>\n<li>si \u2013 The speed at which memory is fetched from disk.<\/li>\n<li>So \u2013 Rate at which memory is swapped out to disk.<\/li>\n<\/ul>\n<p>4. <strong>io \u2013 Statistics of inputs and outputs<\/strong><\/p>\n<ul>\n<li>bi \u2013 The number of blocks a block device receives every second.<\/li>\n<li>bo \u2013 The number of blocks sent per second to the block device.<\/li>\n<\/ul>\n<p>5.<strong> scheduling \u2013 System statistics<\/strong><\/p>\n<ul>\n<li>in \u2013 The number of system interrupts.<\/li>\n<li>cs \u2013 A measure of how many context switches are done per second.<\/li>\n<\/ul>\n<p>6. <strong>CPU \u2013 CPU Statistics<\/strong><\/p>\n<ul>\n<li>us \u2013 The amount of CPU time devoted to non-kernel processes.<\/li>\n<li>Sy \u2013 Estimates how much CPU time is spent on kernel tasks.<\/li>\n<li>id \u2013 CPU idle percentage.<\/li>\n<li>WA \u2013 Duration of CPU time waiting for input\/output.<\/li>\n<li>st \u2013 Percentage of CPU time that is stolen by a virtual machine.<\/li>\n<\/ul>\n<h2><span id=\"Check_Resource_Usage_Using_SAR_Command\"><strong>Check Resource Usage Using SAR Command<\/strong><\/span><\/h2>\n<p>Using the -o option, the <strong>SAR command<\/strong> saves the results to the specified file in addition to displaying them on the output screen.\u00a0<\/p>\n<p>Almost anyone can collect information about an organization\u2019s performance using system activity flags. SAR will only show CPU monitoring activity if no flags are specified by the user.\u00a0<\/p>\n<figure><\/figure>\n<h2><span id=\"Other_ways_to_Check_CPU_Core_Usage_or_Monitor_CPU_Utilization_using_Nmon_Tool\"><strong>Other ways to Check CPU Core Usage or Monitor CPU Utilization using Nmon Tool<\/strong><\/span><\/h2>\n<ul>\n<li><strong>nmon command<\/strong><\/li>\n<\/ul>\n<p>A system administrator can use nmon to monitor CPU, memory, and top processes. Installation is as follows:<\/p>\n<p>sudo apt install nmon ## Debain\/ubuntu ##<\/p>\n<p>sudo dnf install nmon ## fedora ##<\/p>\n<p>sudo yum install nmon ## centos\/rhel ##<\/p>\n<figure><\/figure>\n<h2><span id=\"Measure_CPU_Usage_using_GUI_Tools\"><strong>Measure CPU Usage using GUI Tools<\/strong><\/span><\/h2>\n<p><strong>Laptop\/desktop GUI tools<\/strong><\/p>\n<p>On remote servers, the above tools and commands can be quite useful. gnome-system-monitor can be used on local systems with an X GUI installed. This tool lets you monitor and control your system\u2019s processes. In addition to monitoring and controlling processes, you can send signals and terminate them.<\/p>\n<p><strong>\u201c$ gnome-system-monitor\u201d<\/strong><\/p>\n<p>The gnome-system-monitor also provides an overview of the resource usage on your system, including the allocation of memory and CPU.<\/p>\n<figure><\/figure>\n<h2><span id=\"Glances_Allows_you_to_see_CPU_Utilization\"><strong>Glances Allows you to see CPU Utilization<\/strong><\/span><\/h2>\n<p>Glances is among the open-source tools for monitoring Linux systems I mentioned in my article. In this article, I will discuss Glances in more detail. Those of you who have read my previous article may recognize some of this information, but you may also learn something new.<\/p>\n<p>The Python code in Glances makes it cross-platform. Python can be installed on Windows and other hosts as long as they have the latest version of Python installed. Many Linux distributions (Fedora is my choice) have glances in their repositories. For those without GitHub or using another operating system (like Windows), Glances\u2019 GitHub repo has instructions for downloading and installing it.<\/p>\n<p>While you run the commands in this article, I suggest you run Glances on a test machine. As an alternative, you can explore Glances on a virtual machine (VM) if you don\u2019t have access to a physical host; however, a VM does not have any real hardware.<\/p>\n<p><strong>Launch Glances on a Linux<\/strong> host by opening a terminal window and entering the command glances.<\/p>\n<p>In addition to the main sections \u2014 Summaries, Processes, and Alerts \u2014 Glances also has a sidebar. Let\u2019s proceed to learn how to use Glances now.<\/p>\n<h2><span id=\"Final_Words\"><strong>Final Words<\/strong><\/span><\/h2>\n<p>Checking <strong>CPU usage command in Linux \/ Ubuntu <\/strong>can be done in several ways. Utilizing Linux tools or third-party applications are the primary methods outlined in this guide. Tracking your processor\u2019s usage and performance with these commands will give you more control over your system.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The CPU utilization in Linux determines much of a system\u2019s performance. Monitoring how this resource is used will ensure that the limited processing power is used as effectively as possible. Monitored Linux CPU usage helps debug processes, manage system resources, make real-time decisions, and evaluate systems. Find out how to check CPU usage in Ubuntu<\/p>\n","protected":false},"author":3,"featured_media":3076,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dedicated-servers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/comments?post=3233"}],"version-history":[{"count":0,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/posts\/3233\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media\/3076"}],"wp:attachment":[{"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/media?parent=3233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/categories?post=3233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/foghosting.com\/blog\/wp-json\/wp\/v2\/tags?post=3233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}