How To Check CPU Utilization In Linux via Commands

How to check cpu utilization in Linux via command. CPU usage command to show the top CPU consuming process in Linux. Using these commands one can check CPU utilization in Linux by a process; Linux CPU usage per process.

Read below to find about the commands to check CPU and memory utilization in Linux:

top

top commands displays Linux processes in real-time. top provides an ongoing look at processor activity in real time. It displays a listing of the most CPU-intensive tasks on the system, and can provide an interactive interface for manipulating processes. It can display system summary information as well as a list of processes or threads currently being managed by the Linux Kernel. It can sort the tasks by CPU usage, memory usage and runtime.

When operating top, the two most important keys are the help (‘h’ or ‘?’) key and quit (‘q’) key. Alternatively, you could simply use the traditional interrupt key (‘^C’) when you’re done.

iostat

The iostat command reports Central Processing Unit (CPU) statistics and input/output statistics for devices, partitions and network filesystems (NFS). The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates.

The iostat command generates reports that can be used to change system configuration to better balance the input/output load between physical disks.

The first report generated by the iostat command provides statistics concerning the time since the system was booted. Each subsequent report covers the time since the previous report. All statistics are reported each time the iostat command is run. The report consists of a CPU header row followed by a row of CPU statistics. On multiprocessor systems, CPU statistics are calculated system-wide as averages among all processors.

vmstat

vmstat reports virtual memory statistics. vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.

The commans takes the following sytnax:
vmstat [options] [delay [count]

  • options are the command line arguments, such as
    a {display active and inactive memory}, f {displays the number of forks since boot}, m {displays slabinfo}, s {displays event counters and memory statistics}, d {report disk statistics} and many others.
  • delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
  • count is the number of updates. In absence of count, when delay is defined, default is infinite.

When -a is used alongwith the command, it displays active/inactive memory.

The vmstat command shows the following percentages of total CPU time.

  • us: Time spent running non-kernel code. (user time, including nice time)
  • sy: Time spent running kernel code. (system time)
  • id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
  • wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
  • st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.

htop

htop is an interactive process viewer command. It is similar to top, but allows you to scroll vertically and horizontally, so you can see all the processes running on the system, along with their full command lines. Using htop command, tasks related to processes (killing, renicing) can be done without entering their PIDs.

ps

ps display the status of current processes. This command, only those processes that are running with your effective user ID and are attached to a controlling terminal are shown. Additional categories of processes can be added to the display using various options. ps displays in tabular form the process ID, under PID; the controlling terminal (if any), under TT; the cpu time used by the process so far, including both user and system time, under TIME; the state of the process, under S; and finally, an indication of the COMMAND that is running.

How To Check CPU Utilization In Linux via Commands originally posted on Source Digit – Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos.