How to check CPU memory usage in Linux command?

The htop command is a powerful and interactive process viewer for Unix-like systems, typically used in terminal environments. Its purpose is to provide users with a more convenient and user-friendly way to monitor system resources and manage processes compared to the traditional top command

1.Interactive Interface

htop presents system resource usage in a visually appealing and interactive manner, with color-coded bars and menus, making it easier for users to interpret and navigate.

Detailed Process Information

It displays detailed information about running processes, such as their CPU and memory usage, process ID (PID), user, priority, and more. This information can help users identify resource-intensive processes and troubleshoot performance issues.

Header Information:

At the top, you’ll see basic system information such as the hostname, uptime, load average, and the current time.

Process List

Below the header, you’ll see a list of processes running on your system. Each row represents a single process.

the basic details of the process information displayed by htop:

PID (Process ID):

Each process is assigned a unique identification number known as the Process ID. This is a numerical value assigned by the operating system to identify the process

USER

This column displays the username of the user who owns the process. It indicates which user initiated or is running the process

PRI (Priority)

The priority of the process determines its scheduling precedence. Lower numbers indicate higher priority. Processes with higher priority are scheduled to run before those with lower priority.

NI (Nice Value)

The nice value represents the niceness of a process, which is a measure of its priority relative to other processes. Negative values indicate higher priority, while positive values indicate lower priority.

VIRT (Virtual Memory)

This column shows the total virtual memory usage of the process. It includes all memory that the process can access, including memory that may be swapped out to disk.

RES (Resident Memory

Resident memory refers to the portion of virtual memory that is currently held in RAM (random-access memory) and is actively being used by the process.

SHR (Shared Memory)

Shared memory represents the portion of memory shared among multiple processes. It includes memory segments that are shared between processes.

S (State)

The state column indicates the current state of the process. Common states include:

  • R: Running
  • S: Sleeping
  • D: Disk sleep (waiting for I/O)
  • Z: Zombie (terminated but still has an entry in the process table)
  • T: Stopped
%CPU (CPU Usage)

This column displays the percentage of CPU time consumed by the process since the last update.

%MEM (Memory Usage)

The %MEM column shows the percentage of physical memory (RAM) used by the process

TIME+ (CPU Time):

CPU time represents the amount of time the process has spent executing on the CPU. It includes both user and system time.

Command

The Command column displays the name of the executable or command associated with the process.

These are the basic details provided by htop about each process running on your system, helping you monitor resource usage and manage processes effectively.

Interactive Features
  • htop provides interactive features to manage processes:
    • Arrow keys: Navigate through the process list
    • F9: Kill a selected process (You’ll be prompted to confirm)
    • F2: Enter the setup menu to customize settings
    • F5: Toggle between different system meters (CPU, memory, etc.)
    • F6: Sort processes by various criteria (CPU%, MEM%, etc.)
    • F10 or Q: Quit htop
Color Codes:

htop uses color codes to highlight different aspects of processes and system usage, making it easier to identify resource-intensive processes or system components.

Footer Information:

At the bottom, you may see additional information such as totals for CPU and memory usage.

Overall, htop provides a more user-friendly and interactive way to monitor system processes and resource usage compared to the traditional top command.



Leave a Comment