Home > System Tutorial > LINUX > body text

How to find the most running processes by memory and CPU usage in Linux

王林
Release: 2024-02-09 10:40:25
forward
544 people have browsed it

Most Linux users use the pre-installed default system monitoring tools to check memory, CPU usage, etc. In Linux, many applications run in the background as daemons, consuming more system resources. You can use various gadgets or terminal commands, or you can use a single command to display all running processes by memory and CPU usage. After checking the RAM and CPU load, you can determine which application to kill.

Despite the heavy-duty system monitoring tools, a simple command can display the current CPU and memory usage of the system, saving you time and energy. The commands are easy to use, lightweight, and don't take up too many system resources to display ongoing CPU and memory load. In this article, we will explain how to use the ps command to display running processes by memory and CPU usage.

In Linux, ps represents process status. It runs on Linux and Unix-like operating systems and displays CPU and memory usage in PID. It also allows you to display top applications that consume system resources faster.

1. Overall system reporting through commands

ps command generates a report with PID, timestamp, and TTY; records which application has been running for how long, what the current status is, and the CPU and memory usage reported by the running process . The ps command below will print the overall status of running processes by memory and CPU usage.

$ ps aux
Copy after login
如何在 Linux 中按内存和 CPU 使用率查找运行次数最多的进程

You can also run a short command to view the CPU and memory usage of a specific package.

$ ps aux --sort 
Copy after login

The following ps command with the *-A* option will print the process ID, timestamp, and TTY to the terminal screen.

ps -A
Copy after login

2. View running processes by memory and CPU usage

So far, we have learned what the ps command is, how it works, and how to view the overall status through the ps command on Linux. We will now examine the CPU and memory usage of the processes running on the machine. Please execute the following ps command given below to view the memory or RAM usage of the running processes on your Linux machine.

$ ps aux --sort -%mem
Copy after login
如何在 Linux 中按内存和 CPU 使用率查找运行次数最多的进程

Similarly, you can also get the statistics and usage summary of the CPU on your Linux system through the ps command given below.

如何在 Linux 中按内存和 CPU 使用率查找运行次数最多的进程
$ ps aux --sort -%cpu
Copy after login

3. Get usage statistics by user


If your system has multiple users, you can filter out ps output data by user. The following commands will help you understand how many resources each user is using.

ps -u user
Copy after login

If you want to get the report by running the system thread, then execute the following ps command given below.

ps -L 4264 
Copy after login

The following commands will be the most useful ones you need to run from time to time. To view the top ten processes using the most memory and CPU, execute the following ps command on a terminal shell.

如何在 Linux 中按内存和 CPU 使用率查找运行次数最多的进程
$ ps aux --sort -%mem | head -10$ ps aux --sort -%cpu | head -10
Copy after login

4. 如何查看更多命令选项


到目前为止,我们已经通过了一些最常用的 ps 命令来查看 Linux 系统上的内存和 CPU 使用情况下正在运行的进程。如果您需要更多语法或帮助,请通过终端 shell 查看 ps 手册和帮助部分。

$ man ps $ ps --help
Copy after login

但是,您也可以尝试使用默认的系统监控工具来检查文件系统使用情况、内存使用情况和 CPU 使用情况。

如何在 Linux 中按内存和 CPU 使用率查找运行次数最多的进程

每个 Linux 发行版都提供了一个 GUI 工具来监视系统资源。请从您的软件包列表中打开该应用程序并检查基于图形用户界面的系统使用情况。

小结

ps是一个预装系统工具,所以我们不需要在我们的 Linux 机器上进行任何额外的安装。它从核心内核和硬件级别提取数据,因此我们不会得到任何误导性的输出。

The above is the detailed content of How to find the most running processes by memory and CPU usage in Linux. For more information, please follow other related articles on the PHP Chinese website!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!