Most Linux users use the default system monitor tool that comes pre-installed with the distribution for checking memory, CPU usage, and CPU temperature. In Linux, many applications run in the system background as a daemon to keep another main tool active or live which consumes a bit more system resources. In Linux, you can use various small tools or terminal commands or use one single command that shows all the running processes by memory and CPU usage. After checking the RAM and CPU load, you can determine which application you want to kill.
See Running Processes by Memory and CPU Usage
A simple command can save your time and effort by showing the current CPU and Memory usage on the system despite using heavy system monitoring tools. Using commands is handy, lightweight, and does not take much system resource for displaying the ongoing CPU and memory load. In this post, we will see commands to display the running processes by memory and CPU usage using the
In Linux, the ps stands for process status. It runs on Linux and Unix-like operating systems to prepare CPU and memory usage with PID. Moreover. it allows you to display the top applications that consume the system resource at a higher rate.
1. Overall System Report via
The ps command generates a report with PID, timestamp, and the TTY; that keeps the record of which application is running for how many minutes and what is the current status along with the CPU and memory usage for the running processes report. The following ps command will print the overall status for running processes by memory and CPU usage.
$ ps aux
You can also run a short function to see the CPU and memory usage for a specific package.
$ ps aux --sort <column_name>
The following ps command with an -A flag will print the process ID, timestamp, and the TTY on the terminal screen.
2. See Running Processes by Memory and CPU Usage
So far we have taken ideas about the ps command on what it is, how it works, and how to see overall status through the ps command on Linux. We will now check the CPU and memory usage for the running processes on the machine. Please execute the following ps command given below to see the memory or the RAM usage for the running processes on your Linux machine.
$ ps aux --sort -%mem
In a similar way, you can also get the statistics and the usage summary of the CPU on your Linux system through the following ps command given below. As you can see that the -sort syntax is used in both CPU and memory commands, it actually filters out the data for CPU and memory usage on the machine.
$ ps aux --sort -%cpu
3. Get Usage Statistics by User
If your system has more than one user, you can filter out ps output data user-wise. The following command will help you to understand how many resources every user is using.
ps -u user
If you want to get the report by running systems threads, execute the following ps command given below.
ps -L 4264 by there
The following commands would be the most useful commands that you would need to run every now and then. To view the top ten processes that are using the highest memory and CPU, execute the following ps commands on your terminal shell.
$ ps aux --sort -%mem | head -10 $ ps aux --sort -%cpu | head -10
Extra Tip: Don’t Forget The Default System Monitoring Tool
So far now, we have gone through a few most ps commands to see the running processes by memory and CPU usage on a Linux system. If you need more syntaxes or help, please see the ps manual and help section through your terminal shell.
$ man ps $ ps --help
However, you can also try the default system monitor tool to check the filesystem usage, memory usage, and CPU usage.
Every Linux distribution provides a GUI tool to monitor the system resource. Please open that application from your package list and check the graphical user interface-based system usage.
Since ps is a pre-installed tool, so we don’t need to make any additional installations on our Linux machine. It pulls data from the core kernel and hardware-level so we do not get any misleading output. In the entire post, I’ve described the ps command to monitor the running processes by memory and CPU usage.
Please share it with your friends and the Linux community if you find this post useful and informative. You can also write down your opinions regarding this post in the comment section.