Always on top show ram and cpu usage ubuntu năm 2024

Linux is an open-source and highly popular operating system, and it is the preferred option for deploying servers and applications on the Internet. It is very popular due to its command-line interface and built-in tools which help you to perform your tasks quickly and save a lot of time.

Sometimes your application or website is very slow or unresponsive due to high memory and CPU usage. In this case, you can use the ps and top command to identify which processes are eating all the resources on your system.

In this post, we will explain how to find top memory and CPU resource-consuming processes in Linux.

Use ps Command to Find Top Processes

ps is a Linux command-line utility with many options that helps you to display output in different formats.

To list all running processes in Linux, run the following command:

ps aux

This will show you an overview of all running processes:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] You can use the ps command with –sort argument to sort the output by memory and CPU usage.

The syntax for using the sort argument is:

ps aux --sort

To find the top running processes by CPU usage, run the following command:

ps aux --sort -%cpu

Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND vyom 8115 7.8 3.0 25770108 233784 tty2 Sl+ 17:58 1:37 /opt/google/chrome/chrome --type=renderer --enable-crashpad --crashpad-handler-pid=2815 --enable-crash-reporter=373d0de2-e0c8-419c-b983-084c773fcd79, --display-capture-permissions-policy-allowed --change-stack-guard-on-fork=enable --lang=en-GB --num-raster-threads=1 --renderer-client-id=82 --launch-time-ticks=3564377766 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,7343938639469663677,16234295293987540603,131072 --enable-features=PasswordImport vyom 8164 6.2 3.0 25705000 233456 tty2 Sl+ 17:58 1:16 /opt/google/chrome/chrome --type=renderer --enable-crashpad --crashpad-handler-pid=2815 --enable-crash-reporter=373d0de2-e0c8-419c-b983-084c773fcd79, --display-capture-permissions-policy-allowed --change-stack-guard-on-fork=enable --lang=en-GB --num-raster-threads=1 --renderer-client-id=85 --launch-time-ticks=3576904510 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,7343938639469663677,16234295293987540603,131072 --enable-features=PasswordImport vyom 2806 4.4 4.5 17565904 343660 tty2 SLl+ 17:01 3:26 /opt/google/chrome/chrome --enable-crashpad vyom 2314 4.3 2.9 3472696 222248 tty2 Rl+ 17:00 3:22 /usr/bin/gnome-shell To find the top running processes by memory usage, run the following command:

ps aux --sort -%mem

Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND vyom 2806 4.4 4.5 17562832 343688 tty2 SLl+ 17:01 3:26 /opt/google/chrome/chrome --enable-crashpad vyom 8115 7.8 3.0 25770108 232204 tty2 Sl+ 17:58 1:38 /opt/google/chrome/chrome --type=renderer --enable-crashpad --crashpad-handler-pid=2815 --enable-crash-reporter=373d0de2-e0c8-419c-b983-084c773fcd79, --display-capture-permissions-policy-allowed --change-stack-guard-on-fork=enable --lang=en-GB --num-raster-threads=1 --renderer-client-id=82 --launch-time-ticks=3564377766 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,7343938639469663677,16234295293987540603,131072 --enable-features=PasswordImport vyom 8164 6.1 3.0 25705000 230116 tty2 Sl+ 17:58 1:16 /opt/google/chrome/chrome --type=renderer --enable-crashpad --crashpad-handler-pid=2815 --enable-crash-reporter=373d0de2-e0c8-419c-b983-084c773fcd79, --display-capture-permissions-policy-allowed --change-stack-guard-on-fork=enable --lang=en-GB --num-raster-threads=1 --renderer-client-id=85 --launch-time-ticks=3576904510 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=0,i,7343938639469663677,16234295293987540603,131072 --enable-features=PasswordImport If you want to show only the top 10 memory consuming processes, run the following command:

ps aux --sort -%mem | head -10

If you want to show only the command name instead of the full path of the command, run the following command:

ps -eo pid,ppid,cmd,comm,%mem,%cpu --sort=-%mem | head -10

Output:

PID PPID CMD COMMAND %MEM %CPU 2806 1 /opt/google/chrome/chrome - chrome 4.5 4.3 8164 2828 /opt/google/chrome/chrome - chrome 3.2 6.2 8115 2828 /opt/google/chrome/chrome - chrome 3.0 7.8 2314 2176 /usr/bin/gnome-shell gnome-shell 2.9 4.4 2996 2828 /opt/google/chrome/chrome - chrome 2.4 0.5 8074 2828 /opt/google/chrome/chrome - chrome 2.4 0.8 7520 2828 /opt/google/chrome/chrome - chrome 2.4 0.3 8175 2828 /opt/google/chrome/chrome - chrome 2.2 0.3 2858 2823 /opt/google/chrome/chrome - chrome 2.2 3.8

Also Read

How to Check Linux CPU Usage or Utilization

Use the top Command to Find Top Processes by Memory and CPU Usage

top is another built-in Linux command-line utility that can be used to show all running processes in Linux. You can use various options with the top command to filter the output based on your requirements.

You can use the top command with the -o flag to show the top memory consuming processes:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 0

Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 1

If you want to display only the top 10 memory consuming processes, run the following command:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 2

Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 3

If you want to display only the top 10 CPU-consuming processes, run the following command:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 4

Output:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.1 0.1 160716 9904 ? Ss 16:58 0:06 /sbin/init splash root 2 0.0 0.0 0 0 ? S 16:58 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I< 16:58 0:00 [rcu_par_gp] root 6 0.0 0.0 0 0 ? I< 16:58 0:00 [kworker/0:0H-kb] root 9 0.0 0.0 0 0 ? I< 16:58 0:00 [mm_percpu_wq] root 10 0.0 0.0 0 0 ? S 16:58 0:00 [ksoftirqd/0] root 11 0.1 0.0 0 0 ? I 16:58 0:05 [rcu_sched] root 12 0.0 0.0 0 0 ? S 16:58 0:00 [migration/0] 5

Also Read

How to Check Size of Files and Directory on Linux

Conclusion

In this post, we explained how to find top CPU and Memory consuming processes in Linux. You can use these commands to troubleshoot performance-related issues in Linux. Try it on VPS hosting from Atlantic.Net!

How to see RAM and CPU usage in Ubuntu?

Click on the Show apps button on your system's main screen, and select Terminal. Select the Resources tab in the new window, and you'll see a complete graphical representation of CPU and RAM usage.nullHow to check CPU and memory utilization in Linux - XDA Developerswww.xda-developers.com › how-check-cpu-memory-utilization-linuxnull

How do I see top memory usage in Linux?

Check Which Application is Using the Maximum Memory in Linux.

Using the top Command. The top command is a real-time system monitor that provides information about the system's resource usage, including memory usage. ... .

Using the htop Command. ... .

Using the ps Command. ... .

Using the free Command. ... .

Using the /proc/meminfo File..

How to check CPU utilization in Linux using top command?

Use the "top" command in conjunction with "ps" for real-time monitoring. Open a terminal and run: The "top" command provides an interactive interface that continuously updates information about system processes, including CPU utilization. It displays the most CPU-intensive processes at the top of the list.nullHow to Check CPU Utilization in Linux? - Scaler Topicswww.scaler.com › topics › how-to-check-cpu-utilization-in-linuxnull

How to check RAM usage real

You can use the “System Monitor” tool, which is Ubuntu's default system resource and process monitoring tool. Navigate to the Ubuntu Dash or Show Applications, search for “System Monitor”, open it, and click on the “Resources” tab to view memory usage.nullHow to Check RAM Usage on Ubuntu | Linux Tutorials for Beginnerswebhostinggeeks.com › howto › how-to-check-ram-on-ubuntunull