Open In App

How to Find Top Running Processes by Memory and CPU Usage

Last Updated : 26 Oct, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Every current (running) instance of a program is referred to as a process in Linux. There are running processes on every instance of the Linux operating system. , SSHd, SSH processes, and cron jobs are a few examples. A process is started by any application that has to be used. These processes frequently produce new processes.

In Unix, each command you issue initiates or starts a new process. You initiated a process when you used the df command to display the amount of disc space available.

Processes in Linux

  • UID – Associated user ID for this process.
  • PID –  ID of the process.
  • PPID – ID of the parent process.
  • %CPU – CPU utilized by the process.
  • %MEM – Memory utilized by the process.
  • STIME – Start time of the process.
  • TIME – Time is taken by the process.
  • COMMAND – The command that started this process.

In a Linux system, various types of processes exist. User processes, daemon processes, & kernel processes are some examples of these categories.

Types of Processes:

  • Foreground Processes: The initialization and management of foreground processes – also known as interactive processes – take place through a terminal session. In other words, these processes cannot be initiated automatically as components of the system’s functions or services; a user connection is required.
  • Background Processes: Background processes, often known as non-interactive or automatic processes, are those that are not linked to a terminal and do not require user input.

User Processes: 

A user process is a program that starts and executes in user space and is initiated by an ordinary user account. An ordinary user process does not have special admittance to the computer processor as well as to system files that do not belong to the user who began the process unless it is operated in a manner that grants the process specific permissions.

Daemon Process:

A program that is made to operate in the background, usually controlling some sort of ongoing service, is known as a daemon process. A daemon process may keep an eye out for incoming service access requests. The httpd daemon watches for requests to browse online pages.

Or a daemon could be designed to start operations on its own over time. For illustration, the crond daemon’s purpose is to start cron jobs at predetermined times.

Daemon processes are often executed as non-root users by such a user account that is devoted to the service, even though they are normally handled as services by a root user. A system is more protected from attacks when daemons are executed under distinct user accounts. Daemons are frequently launched by systems at boot time and kept active until the system is closed. Daemons can also be launched or stopped immediately, configured to run at specific system run levels, and, in some situations, notified to dynamically reload configuration data.

Kernel Processes:

Only kernel space is where kernel processes run. They resemble daemon processes in many ways. The main distinction is that kernel processes are more potent than daemon processes which run in user space because they have complete admittance to kernel data structures. Additionally, daemon processes are more adaptable than kernel processes. A daemon process’s behavior can be modified by altering its configuration files and restarting the service. However, modifying kernel processes can necessitate recompiling the kernel.

System/Process States:

The system gives a process a state when it is created. The process’s current state is described in the state section of the process description.

The two states described below are what most processes are in:

  • an activity executing on the CPU (a running process)
  • a task not using the CPU (a not-running process)

On a single CPU, always one process can be active at once. All other processes must pause or transition to another state. Because of this, a process that isn’t active shows in a distinct state. There are the following states:

  • Runnable state
  • Sleeping state
  • Uninterruptable sleep state
  • Defunct state

Running Processes:

The CPU is the most valuable resource in the entire system. A running process is a process that is currently consuming the CPU while it is running. To view the status of each process, use the “ps” and “top” commands. When a process is active, the state field displays R, which stands for Running.

Find Top Running Processes by Memory and CPU Usage:

1. Using htop command:

“htop” is a useful substitute for “top” command – the standard process monitoring tool which comes pre-installed on all operating systems running Linux. htop is a real-time process monitoring software for Linux/Unix-like systems, Users can also interact with this utility. It might be thought of as the Linux equivalent of Task Manager in Windows. Htop is a more interactive program because it allows for value and tab flipping using the mouse and keyboard.

Users of Debian and Ubuntu can quickly install it by running the command below:

sudo apt-get install htop

 

If you are using fedora then execute the below command:

 sudo dnf install htop

And if you are a user of Arch then you have to run this command:

 pacman -S htop

when asked for a password simply type your password and then press enter. Launch the htop by simply running the htop command.

htop

launching htop

The CPU and memory use are displayed in the top-left panel of the screen. Sort the process by top CPU and memory usage: You can see the top running process by memory and CPU by sorting them. We can sort the processes using the htop command and any specific column by pressing the F6 key and then press enter.

htop

2. Using system monitor/task manager:

If you are using Ubuntu then simply open the system monitor application by simply searching it.

 

Then you can see the processes and the resources consumed by each of them. To find the top process by CPU and memory usage press on the %CPU and Memory and they will be arranged in a top-down manner according to the consumption.

system monitor

In Linux Mint, you can open task manager and sort the processes according to the memory and CPU usage by pressing on the CPU and RSS tab.

task manager


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads