Friday, December 08, 2023

How do I find out the CPU and memory utilization of an application on Linux?

To find out the CPU and memory utilization of a specific application on Linux, you can use a combination of commands such as ps, top, or htop. Here are some approaches:

1. Using ps Command

The ps command provides information about processes. You can use it with options to filter information about a specific application.

ps aux | grep "application_name"

Replace "application_name" with the name or part of the name of your application. This will show you details about the application's process, including its PID (Process ID). You can then monitor its CPU and memory usage.

2. Using top or htop Command:

Both top and htop provide real-time information about system resources, including CPU and memory usage. You can launch them and then use their search or filtering features to locate the specific application.

For top:

top

Once in top, press 'O' to enter the filter option, and then enter the application name.

For htop:

htop

In htop, start typing the application name, and it will be filtered accordingly.


3. Using pidof and pmap Commands:

If you know the PID of the application, you can use pmap to display detailed information about the memory usage.

pidof application_name
pmap <pid>


Replace "application_name" with the name of your application, and <pid> with the actual Process ID you obtained from the pidof command.

4. Using pgrep and pmap Commands:

You can also use pgrep to find the PID and then use pmap:

pgrep -o "application_name"
pmap <pid>


Replace "application_name" with the name of your application and <pid> with the actual Process ID.

Choose the method that best fits your needs and preferences. These commands can help you monitor and analyze the resource utilization of a specific application on your Linux system.

No comments: